2周前,我在项目中使用了ElaticSearch(2.4.1版),如果我在查询字符串中指定field,我会遇到问题。
我想使用Kuromoji插件和n-gram标记器来搜索日语数据。
在我的查询中,如果我没有指定字段(例如:"Content"),我会在结果中收到2条记录。
{
"query" : {
"bool" : {
"must": {
"query_string": {
"query":"Software"
/*,"fields":["Content"] <-- not specify this field*/
}
}
}
}
}但是当我在上面的查询中使用"Content“字段时,结果没有记录。(在我的项目中,我想在"Content“字段中进行搜索。)
我还在步骤1中使用了属性"highlight“,但结果中没有包含"highlight”块
{...
"highlight": {
"pre_tags" : ["<tag1>"],
"post_tags" : ["</tag1>"],
"fields" : {
"*" : {} /* or use "_all" */
}
}
}我想问一下:在上面的步骤2中,在查询字符串中指定了什么字段?product.Content,还是其他什么?
如果我不使用Kuromoji插件,步骤2中的查询结果有2条记录。所以我认为Kuromoji插件与结果相关。有人能帮我解决这个问题吗?
以下是我在yaml中的映射和配置:
{...
"mappings": {
"product" : {
"properties" : {
"Content" : {
"index": "not_analyzed",
"search_analyzer": "ja",
"analyzer": "ja",
"type": "string",
"store": true
} ...
}
}
}
}
index :
analysis :
analyzer :
ja :
type : custom
tokenizer : ja_tokenizer
char_filter : [
html_strip,
kuromoji_iteration_mark
]
filter : [
lowercase,
cjk_width,
katakana_stemmer,
kuromoji_part_of_speech
]
ja_ngram :
type : custom
tokenizer : ngram_ja_tokenizer
char_filter : [html_strip]
filter : [
cjk_width,
lowercase
]
tokenizer :
ja_tokenizer :
type : kuromoji_tokenizer
mode : search
user_dictionary : userdict_ja.txt
ngram_ja_tokenizer :
type : nGram
min_gram : 2
max_gram : 3
token_chars : [letter, digit]
filter :
katakana_stemmer :
type : kuromoji_stemmer发布于 2016-11-01 18:04:35
我在我的映射中发现了问题。在我的映射中,我使用了"Content":{"index":"not_analyzed"},所以它不能搜索"Content“字段。我改成了{"index“:"analyzed"},它解决了这个问题。
https://stackoverflow.com/questions/40340904
复制相似问题