Hi Team,
I'm having very huge boolean query which contains NEAR operator with more than 80k phrase limit, so I'm using span_near to handle NEAR operator in my boolean query, but I can see that if I pass keyword with special characters, it simply getting ignored by elasticsearch, please can anyone help me out on how to handle special characters in span_near query?
Example:
Hey there, special characters are getting stripped during tokenization. You can customize this by specifying the tokenizer you want to use, creating a custom analyzer and reindexing your data. Hope that helps!
Hey Kathleen,
Thanks for the quick reply, really appreciated!!
I already have some custom analyzers indexed on my data, they are working fine with normal query i.e. if I specify them in default fields inside query string then its working and returning matching results.
Please can you share syntax or any other way to implement it on span_near query?
Thanks in Advance!!
Sure, here's a quick demo script using the whitespace analyzer - this will not do anything but tokenize on whitespace, but will return a matching document you want using the query you provided. You can play with this script using additional data and different analyzers to see what works for your data and use case.
But here in span_near we are not specifying it anywhere and if I give body.cs_special_characters inside span_term instead of body then it is throwing error
Is there any syntax or way by which we can specify to use particular analyzer inside span_near query?
Or if you have any other alternative to handle NEAR other than span_near?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.