Analyser not found

Hello, I'm running a search engine with Elasticsearch 6.5 using flask (Python) where documents were indexed with a synonym analyzer, but when installing the application on another server I cannot connect to the synonym file.
Running:

{"query": {"bool":{"must":[{"match":{"article":{"query":<query_term>,"fuzziness":"AUTO"}}}

I'm getting the search results.

However, when running the query with synonym:

{"query": {"bool":{"must":[{"match":{"article":{"query":<query_term>,"fuzziness":"AUTO","operator":"and","analyzer":"synonym"}}}]}}}

I'm getting:

RequestError (400, 'search_phase_execution_exception', '[match] analyzer [synonym] not found')

This is why I believe the problem is in accessing my synonym file.
Can you advise on tests I should run on this particular server to examine if that is the case or what could be the source for the problem?

On which index are you running your search?

The search is run with the ES plug in for Python as follows:

es=Elasticsearch()
res=es.search(index="all_articles_synonyms", body=query_as_json)

Documents were indexed in "all_articles_synonyms"
query_as_json= The jsons I quoted in the question

Can you run the following in Kibana dev console?

GET all_articles_synonyms

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

Thanks for the comment and sorry for missing the formatting issue.
Did I answer your question about the index? Do you have an idea about why ES works differently on different servers?

No. You did not answer this question:

Can you run the following in Kibana dev console?

GET all_articles_synonyms

Thanks for the reminder. Rony is not available right now and he asked me to update this discussion.
Kibana is not installed on the system. I ran the query with curl with the following results:

{"all_articles_synonyms":{"aliases":{},"mappings":{"_doc":{"properties":{"address":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"article":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"title":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index":{"creation_date":"1557043339055","number_of_shards":"5","number_of_replicas":"1","uuid":"MW6BiFAKTzyFnHGwDyTWag","version":{"created":"6060099"},"provided_name":"all_articles_synonyms"}}}}

I formatted the json of our query as below. Is it possible that the structure of the query is causing the problem. e.g "analyzer":"synonym" should not be in the place it is?

{
   "query":{
      "bool":{
         "must":[
            {
               "match":{
                  "article":{
                     "query":"blahblah",
                     "fuzziness":"AUTO",
                     "operator":"and",
                     "analyzer":"synonym"
                  }
               }
            }
         ]
      }
   }
}

Thanks in advance.

As you can see you don't have a synonym analyzer defined in all_articles_synonyms index.

Correct, I don't see the analyzer but it should be there as this is the json used to build it:
{
"settings":{
"index":{
"analysis":{
"analyzer":{
"synonym":{
"tokenizer":"whitespace",
"filter":[
"synonym"
]
}
},
"filter":{
"synonym":{
"type":"synonym",
"synonyms_path":"analysis/aaa_syn.txt"
}
}
}
}
}
}

The file exists in the config\analysis directory.
What am I doing wrong! :confused:

I can't tell. I don't know how you created the index and what was elasticsearch response. Could you tell?

As usual the simplest things are the last we try! I deleted the index and rebuilt it and it is now working.
Thank you for your very prompt and useful help!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.