Array of strings

Hey folks,

I have this mapping for vehicles:

"vehicles" : {
      "type": "text"
}

And documents inside, are like:

"vehicles" : [
       "triumph daytona 750 749 1992",
       "triumph trident 750 2018"
]

My question is, how I can make search query to search for document that contains exactly vehicle: triumph daytona 750 1992 ?

You can run a match query and define the operator to be AND instead of OR (default). See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

Hey David,

I am running query:

'match' => [
                'vehicles' => [
                    'query'                 => "triumph daytona 750 1992",
                    'boost'                 => 3,
                    'operator'              => 'and',
                    'minimum_should_match'  => '100%'
                ]
  ]

But I still get, documents without exact this vehicle but similar, like: triumph daytona 650 2001

Actually, this query works perfect, I had a bug in other OR statement which is not in this match.

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