多字通配符匹配

时间:2018-08-17 14:29:21

标签: elasticsearch

使用php elasticsearch。使用以下代码,搜索将匹配“ JohnDoe”或部分搜索(如“ John”),但当我搜索“ John Doe”时不匹配。

    if (empty($_GET['search'])) {
        $query = [ 'bool' => [ 'must' => [ 'match_all' => (object)[] ]]];
    } else {
        $query = ['query_string' => 
                           [ 'default_field' => 'address', 
                             'query' => '*'.(string)trim($_GET['search']).'*'
]
];
}

   $query =  [ 'wildcard' => 
             [ 'address' => '*'.strtolower((string)trim($_GET['search'])).'*']];


 //Full params as follows.
$params = [
 'index' => 'addresses',
    'type' => 'search',
    'body' => [
        'query' => $query,
        "sort" => [
        "updated" => [ "order" => "desc", "unmapped_type" => "long" ],
        "_id" => ["order" => "desc", "unmapped_type" => "long"] 
    ],
    "track_scores" => true,
    //"min_score" => 1
            ]
        ];

我希望能够基于部分搜索甚至多个单词搜索来搜索地址。

不确定从哪里开始。

0 个答案:

没有答案
相关问题