我正在使用https://github.com/babenkoivan/scout-elasticsearch-driver通过 Laravel Scout 实现 Elasticsearch。Ivan 在 Github 上提到了这一点:
在 Elasticsearch 6.0.0 或更高版本中创建的索引可能只包含一个映射类型。在 5.x 中创建的具有多种映射类型的索引将继续像以前在 Elasticsearch 6.x 中一样运行。Elasticsearch 7.0.0 中将完全删除映射类型。
如果我在这里理解:https : //www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html我要么需要使用:
1) PUT 索引?include_type_name=true
或更好
2) PUT index/_doc/1 { "foo": "baz" }
我被卡住了,因为我不知道如何使用 1) 或 2)
如何添加参数include_type_name=true?
如何在不使用 include_type_name 参数的情况下创建正确的映射?
class TestIndexConfigurator extends IndexConfigurator
{
use Migratable;
/**
* @var array
*/
protected $settings = [
];
protected $name = 'test';
}
Run Code Online (Sandbox Code Playgroud) 我尝试使用Elasticsearch为我的内容实现A-Z导航.我需要的是显示所有结果,例如a,b,c,......等.
我试过了:
"query": {
"match_phrase_prefix" : {
"title" : {
"query" : "a"
}
}
}
Run Code Online (Sandbox Code Playgroud)
上面提到的查询也显示结果,其中字符串中的单词以a开头.例:
"title":"Apfelpfannkuchen",
"标题":"Affogato",
"title":"Kalbsschnitzel a a A ceto Balsamico",
我想只显示第一个单词以a开头的短语.
这里我使用的映射:
$params = array(
'index' => 'my_index',
'body' => array(
'settings' => array(
'number_of_shards' => 1,
'index' => array(
'analysis' => array(
'filter' => array(
'nGram_filter' => array(
'type' => 'nGram',
'min_gram' => 2,
'max_gram' => 20,
'token_chars' => array('letter', 'digit', 'punctuation', 'symbol')
)
),
'analyzer' => array(
'nGram_analyzer' => array(
'type' => 'custom', …Run Code Online (Sandbox Code Playgroud)