本文介绍了如何使用ElasticSearch在字符串字段中搜索完整的短语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想在文档中搜索社交网络营销。全部一起。但我继续得到结果与单词分离。我有以下DSL查询:

I want to search "Marketing in social networks" inside documents. All together. But i continue getting results with words separated. i have the following DSL query:

{
    "fields": ["title"],
    "query": {
        "bool": {
            "should": [{
                "match": {
                    "title": "SEO"
                }
            }],
            "must": [{
                "match": {
                    "content": {
                        "query": "Marketing in social networks",
                        "operator": "and"
                    }
                }
            }]
        }
    }
}

我没有包含此短语和标题的文档,但我也可以使用短语的单词来搜索分割的结果(文档)。我想要严格的搜索。如果没有任何具有此短语的文档不能检索任何文档或仅检索具有该标题的文档。
为什么运算符和不起作用?

I do not have documents that contain this phrase and title but i also get results(documents) with the words of the phrase to search splitted. I want a strict search. If there is not any document that have this phrase do not retrieve any document or only retrieve documents with that title.Why operator and does not work?

推荐答案

短语。请参阅,



{
    "fields": ["title"],
    "query": {
        "bool": {
            "should": [{
                "match": {
                    "title": "SEO"
                }
            }],
            "must": [{
                "match": {
                    "content": {
                        "query": "Marketing in social networks",
                        "type":  "phrase"
                    }
                }
            }]
        }
    }
}

PS:我还没有尝试过。

P.S: I haven't tried it yet.

这篇关于如何使用ElasticSearch在字符串字段中搜索完整的短语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-09 00:21