http://cgit.drupalcode.org/search_api/tree/src/Plugin/search_api/process...
Skips every other result in the array. Normally there's just the one word anyway, but in cases (see below) you have multiple words in a string.
Array
(
[0] => these
[1] => three
[2] => words
)
So the word 'three' is skipped.
I don't know if this is the only case where a string of multiple words is the $value. Also in this case I'm not sure, should the stemmer even do anything. If it should it should however stem all the words not just every other one.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2828148-04.seach_api.stemmer.process.patch | 2.05 KB | ekes |
Comments
Comment #2
ekes commentedComment #3
ekes commentedSo I've looked at this in more detail. Testing different combinations I come up with two instances where $value argument for Stemmer::process contains more than 'word' without spaces. These are: when the tokenizer is not enabled (first) and a field is being indexed; and when a query is being made and it includes "string in quotes".
Without tokenizer, indexing a fulltext field; and query with quotes. Value of $value is like
With when passed through
Results in an array
Add the tokenizer and you just have
If the $value string includes multiple space values like:
Then the output $words is
In all cases here I'm unclear why
is used, why do you want to catch the space deliminator anyway? And I'm certainly still confused by the mod is used to skip values.
Comment #4
ekes commentedSo with the strings I've so far seen being passed into the Stemmer::process it would seem that this makes more sense.
Comment #5
ekes commentedI think I've worked out where the skipping code comes from, if that is correct, then the regex is wrong.
The code on line 113 is:
Which returns for the example above:
However if the code was to capture (as I happened to notice the Porterstemmer module for core search does http://cgit.drupalcode.org/porterstemmer/tree/porterstemmer.module?h=8.x...
Effectively this with the regex used this would be:
Then the example returns:
If the desire is to maintain whitespace between words, then the regex wants changing. Law of unintended consequences suggests this. It does mean, in the core search example linked above that <tag/> angle brackets are returned (I guess no tags names are stemmed) as well as newlines, quotes, spaces etc.
If maintaining whitespace is pointless, then the patch does it just fine.
Comment #6
borisson_Discussed this with @ekes, maintaining whitespace is pointless. Let's get this in.
Comment #7
ekes commented[ Loop-back issue on what I assume was the inspiration/original code. I think the requirements for core and search api here are a bit different, but for completeness, and for anyone trying to unravel these issues sometime in the future https://www.drupal.org/node/2830484#comment-11796251 ]
Comment #8
ekes commentedUh why it do that, it was just a note :)
Comment #9
ekes commentedComment #10
drunken monkeyExcellent, great job!
Committed.
Thanks!