Elastica icon indicating copy to clipboard operation
Elastica copied to clipboard

How to create suggest query with source filtering?

Open honzatrtik opened this issue 7 years ago • 1 comments

Hello!

I'd like to create query like this:

{
    "_source": "suggest", 
    "suggest": {
        "some-suggest" : {
            "prefix": "som",
            "completion" : {
                "field" : "suggest", 
                "size" : 5 
            }
        }
    }
}

Im having troubles with setting _source parameter... So far I have this -

$suggest = new Suggest();
$term = new Suggest\Completion('some-suggest', 'suggest');
$term->setSize(5);
$suggest->addSuggestion($term);
$index = $this->indexFactory->get($domain, $type);
$resultSet = $index->search($suggest);

Calling $index->search($suggest, ['_source' => ['param', 'param']]); did not pass validation rules... Am I missing something?

honzatrtik avatar Feb 12 '18 11:02 honzatrtik

What are you exactly trying to set with the _source -> param ... you have mentioned last? What do you get if you run $suggest->toArray() and print the output?

ruflin avatar Feb 15 '18 22:02 ruflin