Special Character Search in Elasticsearch

Hi All,

I have a nested type document with following structure.

indexName
-- mapping
-- header
-- nested
-- details is neted in that i have documents like
[{
sub doc 1
},
{
sub doc 2
}] etc..

Now i am checking a query on the text with in details nested field which is using wild card "813-0198" the documents belongs to this field has values like 813-0198-112,813-0198-34etc...
if i search with "813-0198" with nested query can i get the all values contains this string or do we need any special analyzer to search special characters in nested type?please help me in this

Thanks
phani

This is largely unrelated to the nested structure; it boils down to how the fields were analyzed.

Under the default analyzer (standard), hyphens are stripped out when the strings are tokenized. For example, 813-0198-112 will be tokenized into [" 813", "0198", "112"]

Similarly, when you search for "813-0198", that'll be tokenized into [ "813", "0198"]. So you'll find any document that contained "813" OR "0198".

If you don't want that behavior, you'll need to configure an analyzer that doesn't tokenize on hyphens (and other special characters that you care about).

Hi ,

Thank you for the reply. I am using full text search on this i.e "text". I am using ES 5.1.1 but it is not working as expected can you please tell me in full text search scenario is it possible to make wild card search?

phani

I suggest you start reading through the Mapping and Analysis portion of the Definitive Guide, as well as the Analysis docs.

The subject is a bit too broad to cover in a forum reply, but the Guide and docs will help you start to understand how mapping/analysis works.

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