-1

ES Query

{
  "bool": {
    "must": [
      {
        "fuzzy_like_this_field": {
          "Product.productInfo": {
            "like_text": "code=9787 Cornichons, qty=1.0, amt=0.89,code=37424 Pasta Spez. frisch, amt=1.29, totalCost=0.0, vat=0.0",
            "fuzziness": 0.5
          }
        }
      }
    ],
    "must_not": [],
    "should": []
  }
}

I want result which matches with code=9787 and amt=0.89, totalCost=100.0, vat=2.0.

However, it returns all results which contain code= or amt= or qty=. It not checks code's, amt's, qty's values.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ranjeet
  • 636
  • 6
  • 12

1 Answers1

0

Fuzzy, in elasticsearch, only handles similar text. E.g. "Cornichons" ~= "Cornicons".

If you want to enable ranges (near to your "like" document), for say the numeric values of (cost, vat, amt, etc...), then add those range queries directly instead of fuzzy search.

Peter Dixon-Moses
  • 3,169
  • 14
  • 18
  • Hey Peter..as per elastic documents fuzzy_like_this_field handles exact similar and near to similar text according to fuzziness value https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-flt-field-query.html and I want those records which are exact similar or near to similar – Ranjeet Feb 10 '16 at 08:38
  • Correct. Similarity is defined by Levenshtein Distance (or the number of **character** replacements required to produce an identical string). It does not know how to identify numeric values in close proximity (small delta). Only text. – Peter Dixon-Moses Feb 10 '16 at 11:23
  • You have any idea/suggestion ? – Ranjeet Feb 10 '16 at 12:36
  • Parse your text string into the appropriately-typed fields which you care about. Index it. Use range queries to define the variances in amt, totalCost and vat you'll accept. – Peter Dixon-Moses Feb 10 '16 at 17:42