-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Root search analyzer doesn't act as default for fields #3102
Comments
The general issue stays the same in new release |
hey @gakhov we will look into this soon hopefully. Thanks for reporting it! |
I have quickly looked into it, and I can see why it happens. The reason is that the analyzer (index/search) are associated with the types, so when using APIs that are not directly using a type, the analyzer can't be derived automatically (just based on the field name). In the above test case, the document gets indexed properly (because it has the type). When using the analyze API, the type information is not there, so it can't derive the analyzer (and we don't expose the ability to provide a type in the analyze API). In the search case, the search is executed on the index as a whole, so again the analyzer can't be derived based on the type, on the other hand, if its executes explicitly on the type (
This behavior mainly comes from the fact that it gets tricky supporting multiple types with different definitions (like analysis) when executing across all types (such as executing against the index without specifying the type explicitly). But I admit its confusing. Requires some thinking into how to improve the behavior if even possible, but just wanted to post it here to explain the logic of how things work now. |
Ah, thank you @kimchy! I didn't figure it out. This behaviour was a big problem for our application and we temporary solved it with specifing the It make fully sense for me to specify the Actually, i thought when i update mapping, P.S. In such situation, I would expect either clean exception from One more comment. It seems in analyze API i can't specify the |
This should be fixable once we have #4081 done. |
As part of #4081, we should remove the type-level analysis settings. |
Closing in favour of #8874 |
Recently, we moved from version
0.19.11
to last stable0.90.0
and found one very strange behavior that looks like an issue.If on the item root level we have specified our custom
index_analyzer
,search_analyzer
(or justanalyzer
), thenindex_analyzer
works well, but not thesearch_analyzer
. Also, fif we update existing mapping with explicitly specifyingsearch_analyzer
on the field level, then it still doesn't seem to work and ES uses standard one.To reproduce:
Create a new index and define our custom analyzer
de_stem
:Put mapping with specified
index_analyzer
andsearch_analyzer
:Try
search_analyzer
for the fieldcontent.body
with Analyze APIActual result:
Expected result:
The right (expected) result still possible to get, but with explicitly specified
search_analyzer
:Index Analyzer is set well
As we see above,
search_analyzer
seems wasn't set, butindex_analyzer
works well.Let's index a document:
If
index_analyzer
was set well tode_stem
the wordApple
should be indexed asappl
, but notapple
(asstandard
analyzer does).Let's search for
appl
first:It works! We get back 1 result:
For the word
apple
, as expected, it doesn't work sincesearch_analyzer
is standard, butindex_analyzer
isde_stem
(so, actual search term will stayapple
, but indexed isappl
):Specifying search analyzer with Put Mapping API doesn't help
Ok, i try to update mapping and specify explicitly
search analyzer
forcontent.body
field on the existing index we created above:Response is
ok
, but the all problems described above stay the same. So, it seems thesearch_analyzer
for the fieldcontent.body
is stillstandard
.The text was updated successfully, but these errors were encountered: