我试图找出更多像这个查询的工作原理(ES 2.X).我用术语向量创建了以下索引.
PUT /test_index
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"text": {
"type": "string",
"term_vector": "yes"
}
}
}
}
}
PUT /test_index/doc/1
{
"text": ["Hello","World"]
}
PUT /test_index/doc/2
{
"text": ["This","is","me"]
}
PUT /test_index/doc/3
{
"text": ["Hello","World"]
}
PUT /test_index/doc/4
{
"text": ["Hello","World","World"]
}
Run Code Online (Sandbox Code Playgroud)
为什么以下查询不返回任何结果?使用第二个查询,我希望至少检索doc 3,它具有相同的doc 1值.
POST /test_index/doc/_search
{
"query": {
"more_like_this": {
"like": "Hello",
"min_term_freq": 1
}
}
}
POST /test_index/doc/_search
{
"query": {
"more_like_this": {
"fields": [
"text"
],
"like": [
{
"_index": "test_index",
"_type": "doc",
"_id": "1"
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
vin*_*_vh 14
默认情况下min_doc_freq为5,因此您的查询无效,因为您的索引不包含至少5个term属性为黄色的文档.因此,min_doc_freq在您的查询中设置为1,它应该工作.
{
"query": {
"more_like_this": {
"like": "Hello",
"min_term_freq": 1,
"min_doc_freq": 1
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2180 次 |
| 最近记录: |