0

I have a method that escapes a query using regular expression, wraps the whole query with asterisk and then send a query to ElasticSearch.

Everything works great except from when a user sends just an asterisk in the query than I get back all documents. I debugged the code and the query that is sent to the server is "*\**", the expected behavior is that all documents containing an asterisk will be returned but the behavio

What am I missing ?

Thanks

keisar
  • 5,266
  • 5
  • 28
  • 28
  • 1
    How are your fields mapped? If you are using standard analyzer, the asterisk is not getting indexed. By the way, wildcard prefix queries are quite inefficient. See this post for more information: http://stackoverflow.com/questions/6467067/how-to-search-for-a-part-of-a-word-with-elasticsearch – imotov May 19 '12 at 20:28
  • Thanks, does the StandardAnalyzer removes all special characters ? – keisar May 20 '12 at 14:01
  • 1
    It does. You can check what an analyzer is doing to your text by running `curl "localhost:9200/twitter/_analyze?analyzer=standard&pretty=true" -d "Text to test"` – imotov May 20 '12 at 17:13
  • If anyone wants to use the above url and they don't have curl (like me :) ) they can use it like this: localhost:9200/twitter/_analyze?analyzer=standard&pretty=true&text=text%20to%20test – keisar May 21 '12 at 07:13

0 Answers0