cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

how to implement match_phrase_prefix query ? #81

Closed damianoporta closed 8 years ago

damianoporta commented 8 years ago

Hello, I should use match_phrase_prefix (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html)

it seems not implemented here, at the moment i am testing the query with this json:

{  
   "fields":[  
      "name"
   ],
   "query":{  
      "match_phrase_prefix":{  
         "name":{  
            "query":"test",
            "slop":3
         }
      }
   }
}

how should i build this query? Thanks!

markstory commented 8 years ago

I think for now you'd have to directly set the query using $query->query()

damianoporta commented 8 years ago

This is the solution:

$query->query(new \Elastica\Query\MatchPhrasePrefix('fullname', ['query' => $args['fullname'], 'slop' => 2]));