我最近開始使用ElasticSearch,似乎無法使其搜索單詞的一部分。如何使用ElasticSearch索引搜索單詞的一部分
例子:我從我的CouchDB在ElasticSearch索引的三個文件:
{
"_id" : "1",
"name" : "John Doeman",
"function" : "Janitor"
}
{
"_id" : "2",
"name" : "Jane Doewoman",
"function" : "Teacher"
}
{
"_id" : "3",
"name" : "Jimmy Jackal",
"function" : "Student"
}
所以,現在,我想搜索包含「母鹿」
curl http://localhost:9200/my_idx/my_type/_search?q=Doe
不返回所有文件任何命中。但如果我搜索
curl http://localhost:9200/my_idx/my_type/_search?q=Doeman
它確實返回一個文件(約翰多曼)。
我正在嘗試使用此URL http://localhost/el/index.php?str=*doe*
。
<?php
require 'vendor/autoload.php';
$client = Elasticsearch\ClientBuilder::create()->build();
$params = array();
$params['index'] = 's3';
$params['type'] = 's3files';
$params['body']['query']['match']['content'] = $_GET['str'];
$result = $client->search($params);
echo "<pre>";
print_r($result);
當我搜索「Doe」時,如何讓ElasticSearch找到John Doeman和Jane Doewoman?
'捲曲的http://本地主機:9200/my_idx/my_type/_search Q =李四*' –
可能的[如何搜索與ElasticSearch一個字的一部分]重複(HTTP://計算器.com/questions/6467067/how-to-search-for-a-part-of-a-word-with-elasticsearch) –
@ apex-meme-lord是的,但我使用php代碼搜索,它沒有顯示正確的結果 –