2
$params = [
            'from' => $from,
            'size' => config('app.pagination'),
            'index' => $index,
            //'type' => $this->type,
            'body' => [
                'query' => [
                    'bool' => [
                        'filter' => [
                            'term' => $where
                        ],
                        'must' => [
                            'multi_match' => [
                                'query' => $match,
                                'fields'=>$fields,
                                'fuzziness' => "AUTO:1,5",
                            ]
                        ]
                    ],
                ]
            ]
        ];

Hello, I don't have a problem with my query above.

For example, I am looking for a pizza. I am writing pizaz again. These queries return the correct records to me.

But I have a problem. It doesn't return anything when you type piz.

How can I solve this problem? I want it to work when I write it missing.

Spartan Troy
  • 949
  • 2
  • 9
  • 13
  • does this answer your question: [Elasticsearch match substring in php](https://stackoverflow.com/questions/35217833/elasticsearch-match-substring-in-php) – Alive to die - Anant Feb 18 '20 at 10:32
  • So how do I add this wildcard query to my values. How should 'must' and 'should' work. – Spartan Troy Feb 18 '20 at 10:59
  • @SpartanTroy, you should use https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html in this , let me know if you need a sample index and query in JSON format as I am not aware of php syntax – Amit Mar 23 '20 at 15:46

1 Answers1

0

Add minimum_should_match parameter to your query.

Using minimum_should_match sets a threshold (absolute number, percentage, or combination of these) for matching clauses in boolean queries.

As you know from docs

If the bool query includes at least one should clause and no must or filter clauses, the default value is 1. Otherwise, the default value is 0.

Ivan Vovk
  • 929
  • 14
  • 28