Fuzzy query exclude exact match


(acastellano) #1

Is there any way to express the 'fuzziness' parameter in terms of a range that excludes exact matches or fuzziness = 0 hits? Basically just a return on fuzzy matches of edit distances 1 and 2?


(Mark Harwood) #2

Use a bool query where a fuzzy match is a must but an exact match is a must_not ?

GET news/_search
{
  "query": {
	"bool": {
	  "must": [
		{
		  "match": {
			"headline": {
			  "query": "accommodation",
			  "fuzziness": 2
			}
		  }
		}
	  ],
	  "must_not": [
		{
		  "match": {
			"headline": {
			  "query": "accommodation"
			}
		  }
		}
	  ]
	}
  }
}

(acastellano) #3

Just what I needed - thank you Mark!


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.