How to sort result set in order of matching words

Hi guys,

I have a couple words "heinz meyer"

my query returns:

  • Heinz A. Meyer
  • Heinz Meyer GmbH Heizung-Sanitär
  • Heinz Meyer
  • Karl-Heinz Meyer GmbH

but i need, order by positions matching like next :

  • Heinz Meyer
  • Heinz Meyer GmbH Heizung-Sanitär
  • Heinz A. Meyer
  • Karl-Heinz Meyer GmbH

my query is:

{
	"query": {
		"bool": {
			"must": [{
				"wildcard": {
					"name": "heinz*"
				}
			}, {
				"wildcard": {
					"name": "meyer*"
				}
			}],
			"must_not": [],
			"should": [],
			"filter": {
				"bool": {
					"must": [{
						"range": {
							"latestRevenueStatistics.revenue": {
								"gte": "0",
								"lte": "40000000"
							}
						}
					}, {
						"range": {
							"latestRevenueStatistics.number_of_employees": {
								"gte": "0",
								"lte": "300"
							}
						}
					}, {
						"term": {
							"addresses.postal_code_length": 5
						}
					}]
				}
			}
		}
	},
	"from": 0,
	"size": 10
}

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