2

I have an uissue in my fuzzy_like_this query If my string contains any Apostrophe then its not searching those values contains in db.

sample

citrus's => search string but results not selecting the apostrophe values instead getting like citrus, so and so.. pls do help me Thanks in advance

2 Answers2

2

elastic search accepts the Apostrophe.so please double check your query

1

6 unicode characters can represent an 'apostrophe' in documents. It can be either u0027, u2018, u2019, u201B, u0091 or u0092

Out of the six, Elasticsearch recognises three unicode characters as 'apostrophe' : u0027, u2018 and u2019.

So, I think your apostrophe must be last 3 unicode character, which Elasticsearch assumes as word boundaries. So, citrus's will be tokenize as citrus only.

Adding a char_filter in your analyzer might help you. All the six characters will be replaced by proper 'apostrophe' u0027

curl -XPUT http://localhost:9200/index_name(your_index) -d '
{
"settings": {
"analysis": {
  "char_filter": { 
    "mycharfilter": {
      "type": "mapping",
      "mappings": [ 
        "\\u0091=>\\u0027",
        "\\u0092=>\\u0027",
        "\\u2018=>\\u0027",
        "\\u2019=>\\u0027",
        "\\u201B=>\\u0027"
      ]
    }
  },
  "analyzer": {
    "quotes_analyzer": {
      "tokenizer":     "standard",
      "char_filter": [ "mycharfilter" ] 
    }
   }
  }
 }
}'
  • thanks for the reply, I have a bit confusion. How do I push this settings into the elastic server or do i need to do this settings while on search query. i am usinh php curl to push and pull data using bulk and fuzzy_like_this respectively – Sujith Divakar Sep 11 '14 at 04:30
  • You need this setting in your Elasticsearch server not while querying. Eg. curl -XPUT http:// .../your_index -d ' and the snippet above – Laishram Krishnananda Singh Sep 11 '14 at 06:37