Closed (fixed)
Project:
Search API
Version:
7.x-1.x-dev
Component:
Framework
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Apr 2011 at 16:31 UTC
Updated:
6 Oct 2025 at 21:43 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
froezibaer commented...and: i tried it on two different installations...
Comment #2
drunken monkeyYou're right, this definitely is a case that should be handled by the module in some way. Force-splitting after 50 characters (or 255 and increasing the field size accordingly) is probably an easy solution, and there doesn't seem much else we can do. Maybe we should then also display a warning that such truncating has occurred during indexing.
However, I'm really curious as to what kind of words you have in your nodes? First I thought about some special language/alphabet that my processor wasn't built for, but … ja, anscheinend eher nicht. ;) Are you using the Tokenizer processor, maybe with custom settings?
Comment #3
drunken monkeyComment #4
klausiSubscribing, I ran into this problem as well. Workaround: enable the tokenizer processor on the workflow tab of your index.
I think the DB search does not split words correctly.
Comment #5
drunken monkeyAh, now that I look at the code, the further tokenizing by the DB backend is only done when the data isn't already tokenized in some way. I assume you activated the HTML filter (which also tokenizes, but only according to HTML tags – therefore containing whole paragraphs as single tokens, if they don't contain HTML tags), but not the Tokenizer, which results in this error.
However, simply letting the DB backend tokenizing also run on already tokenized data isn't good either – this would make the Tokenizer processor rather useless, as you then couldn't configure the tokenizing anymore.
After all, I think people just shouldn't use the DB backend without the Tokenizer preprocessor, it's just not built for that. Maybe we can display a warning when too long tokens are encountered, which then checks whether the Tokenizer is enabled. How about that?
Had both of you the HTML processor enabled and the Tokenizer disabled?
Comment #6
agentrickardSame problem with both processors enabled. Investigating.
Comment #7
agentrickardIn my case, we have some dirty search data in the external source material. e.g.
So here, the truncation is acceptable and just needs error suppression, I suppose. Thoughts?
Comment #8
drunken monkeyYes, in such cases, just catching the error and maybe displaying / logging some explanation is probably the best we can do. They shouldn't throw an exception, in any case.
So, to summarize my proposed solution:
- Check all text tokens (no matter whether tokenized by the processor or the service class) for length.
- When encountering a token that is too long, check whether the standard-tokenizing would solve this:
- - Yes: check whether the "Tokenizer" processor is enabled for the index.
- - - Yes: execute standard tokenizing on the token and set a message for the user to check her Tokenizer settings.
- - - No: execute standard tokenizing on the token and set a message for the user to enable the Tokenizer processor.
- - No: truncate the token to 50 characters and display a message explaining to the user that over-long words were encountered.
What do (all of) you think, would this be a sensible approach?
Or maybe we should also make the maximum word length configurable for database servers?
Comment #9
agentrickardThat all sounds right to me.
I think 50 is perfectly reasonable, at least in English. Quick look suggests the longest 'official' word is 45 characters.
https://secure.wikimedia.org/wikipedia/en/wiki/Longest_word_in_English
For other languages, there's this list: https://secure.wikimedia.org/wikipedia/en/wiki/Longest_words
There are a handful over 50, and it looks like 80 would handle all but the most edge cases (which are generally proper nouns).
Comment #10
agentrickardWhere would this logic be introduced? I might take a crack at it.
Comment #11
drunken monkeyThanks for the offer, but I've already written up a patch. Please see (and test) the attached patch.
I've also added at least rudimentary error handling for strings, which have similar problems with values longer than 255 characters.
If this problem is encountered on a production site (or, maybe rather "when"), we can probably fix this by dynamically increasing the field size in the database.
Comment #12
agentrickardHm. Upgraded to 7.x.1.x-dev, applied the patch and tried the drush command (which works without the patch) and:
Comment #13
agentrickardSlight revision to the patch (in -p1 format).
Still throwing an error I can't track down.
No idea where check_plain() is getting invoked.
In this patch, I removed two issues:
1) $v should be $v['value'] in the preg_split().
2) In the indexItem() method PHP doesn't like &$token['values'] used by reference.
I also don't understand how or why the foreach ($value as $token) loop is supposed to work, given that inside that loop, $value is reset.
Comment #14
drunken monkeyI have to apologize, that patch was really crappy. Sorry that you had to test it, and even tried to figure out what was wrong.
I now rewrote (and, this time, tested) it, should be OK now.
Comment #15
agentrickardI've been there myself. Will test on Monday.
Comment #16
agentrickardThat patch works. I wonder if we can suppress the warning in some cases. When running this via the new drush commands, I could see thousands of these, which I don't really need.
Through the UI, we could also see up to a hundred messages, for instance.
The ability to flag verbose messages would be a nice addition.
Comment #17
drunken monkeyCome to think of it, since indexing is mostly done in cron, using watchdog instead of displaying messages would be preferable anyways …
See the attached patch (although the modification is quite small).
Also interesting would of course be reviews by froezibaer and klausi, before I commit this.
Comment #18
agentrickardWatchdog makes sense here. ++
Comment #19
klausiWorks for me. Can't say much about the code as I'm not that familiar with SearchAPI. I think it would be nice to link the error message "Check the logs for details." to admin/reports/dblog, but that is probably another issue.
Comment #20
drunken monkeyAs I understand it, watchdog isn't fixed on logging to the DB log, so we probably can't do this. Users will just have to know where to find their system logs. And yes, it would be another issue.
Anyways, good to know this works for you, too. Just committed the patch.
Comment #22
BarisW commentedMy indexing fails as well, but that was related to another issue. Linking to it for reference: #1346276: Tokenizer should only run on fulltext fields
Comment #23
sunchaser commentedStill get this error (resulting in not all nodes to be indexed > in fact : only 95% of my nodes are indexed)
An overlong word (more than 50 characters) was encountered while indexing, due to bad tokenizing. Please check your settings for the "Tokenizer" preprocessor to ensure that data is tokenized correctly.Tokenizer preprocessor is enabled and only running on the Body text (fulltext)
Don't know what else to do.
edit : started tearing apart a node that was not being indexed and seemed that the word "één" was the word that the indexer kept on choking up on ...
Is this a documented issue ? > letters with accents not being treated well by the search api indexer ?
Edit : duplicate of http://drupal.org/node/1144620
Comment #24
loko commented#4 work for me. Thank you
Comment #25
basvredelingI had a hard time to index some especially long WKT values (geodata). I ended up indexing them as full text instead of strings and not running any tokenizers or other filters on the field.
Comment #26
ressaThanks @basvredeling, your comment gave me the hint I needed.
I plan to move from Search API Solr to standard Search API with MariaDB and Redis for caching. But when I indexed nodes with Geodata values with the new Standard DB server, I got errors like this:
Under the index I saw this:
Under "Data types", the supported types were listed (Decimal, String, Date, Boolean, Integer, and Fulltext) and then all the unsupported Search API Solr types ...
The Geodata field was set to use "Storage-only", which works only with Solr:
After indexing them as Fulltext instead of strings (the fallback data type for Storage-only), all is well, and there are no errors :)
Now, I just wonder ... should Fallback data type for Storage-only be changed from String to Fulltext?