Fuzzy Search on some selected fields


(Hichem Maalmi) #1

Hi,

We are trying to make a search query that looks for a text in multiple fields with eventually different scores per field and the possibility to make a fuzzy search on some of them.

a sample of a generated query

 {
      "query": {
          "filtered": {
              "query": {
                  "dis_max": {
                      "queries": [{
                          "bool": {
                              "should": [{
                                  "match": {
                                      "subject": {
                                          "query": "test",
                                          "type": "boolean",
                                          "boost": 1,
                                          "fuzziness": "AUTO"
                                      }
                                  }
                              }, {
                                  "match": {
                                      "user.full_name.name": {
                                          "query": "test",
                                          "type": "boolean",
                                          "boost": 1,
                                          "fuzziness": 0
                                      }
                                  }
                              }, {
                                  "match": {
                                      "owner.full_name.name": {
                                          "query": "test",
                                          "type": "boolean",
                                          "boost": 1,
                                          "fuzziness": 0
                                      }
                                  }
                              }],
                              "minimum_should_match": 1
                          }
                      }]
                  }
              }
          }
      },
      "highlight": {
          "fields": {
              "subject": {},
              "user.full_name.name": {},
              "owner.full_name.name": {},
          }
      },
      "sort": ["_score"],
      "size": 10,
      "from": 0
  }

The problem with fuzziness is that once we set it for a subquery( subject in this example ) it gets applied to all other queries (user.full_name and owner.full_name) which is not the wanted behavior.

I wonder if this is the right way to activate fuzziness on some selected fields without affecting the others.

Any help would be appreciated.
Thank you


(system) #2