当type声明为string,Elasticsearch 6.0将显示此错误.
"name" => [
"type" => "string",
"analyzer" => "ik_max_word"
]
Run Code Online (Sandbox Code Playgroud) 我们title在索引中存储了一个字段,并希望将该字段用于两个目的:
title字段上使用ASC排序列出结果而不是分数.索引/过滤器/分析器的定义如下:
array(
'number_of_shards' => $this->shards,
'number_of_replicas' => $this->replicas,
'analysis' => array(
'filter' => array(
'nGram_filter' => array(
'type' => 'nGram',
'min_gram' => 2,
'max_gram' => 20,
'token_chars' => array('letter','digit','punctuation','symbol')
)
),
'analyzer' => array(
'index_analyzer' => array(
'type' => 'custom',
'tokenizer' =>'whitespace',
'char_filter' => 'html_strip',
'filter' => array('lowercase','asciifolding','nGram_filter')
),
'search_analyzer' => array(
'type' => 'custom',
'tokenizer' =>'whitespace',
'char_filter' => 'html_strip',
'filter' => array('lowercase','asciifolding')
)
)
)
),
Run Code Online (Sandbox Code Playgroud)
当我们对title场地进行排序时,我们遇到的问题是不可预测的结果.在做了一点搜索之后,我们sort在ElasticSearch 的手册页末尾发现了这个...( …
我在弹性搜索上按日期排序时遇到问题。根据elasticsearch提供的文档http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_sorting.html
我使用以下代码按日期排序
{"sort":{"posted_on":{"order":"desc"}}}
Run Code Online (Sandbox Code Playgroud)
以下是结果
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 305,
"max_score": null,
"hits": [
{
"_index": "ads",
"_type": "ad",
"_id": "52d6945f1d41c812bf000004",
"_score": null,
"_source": {
"category": "Cars and Bikes",
"description": "Innova 2010(V) DC",
"posted_on": "2014-09-04T18:11:57+00:00",
"slug_id": "innova-2010-v-dc",
"title": "Innova 2010(V) DC"
},
"sort": [
"57"
]
}
,
{
"_index": "ads",
"_type": "ad",
"_id": "5408accf1d41c8b8f1000001",
"_score": null,
"_source": {
"category": "",
"description": "rrrrrrrrrrfsadsadfsadfsa",
"posted_on": "2014-09-04T18:11:57+00:00",
"slug_id": "test", …Run Code Online (Sandbox Code Playgroud)