【问题标题】:elastic search multiple types search弹性搜索多种类型搜索
【发布时间】:2013-02-27 13:06:41
【问题描述】:

我不知道弹性搜索的文档是否很差,或者我只是在错误的地方搜索。我想要做的事情是我想搜索一个特定的索引,但不同类型的不同查询但返回一个结果。例如:

我有一个名为 beta 的索引和索引 test1 和 test2 内的两种类型,我想用一个查询来查询这两种类型:

类型测试1

 {
        "query": {
            "fuzzy_like_this": {
                "fields": ["LastEditorID"],
                "like_text": "Test1",
                "min_similarity": 0.1,
                "max_query_terms": 5
            }
        }
    }

输入 test2

{
    "query": {
        "fuzzy_like_this": {
            "fields": ["LastEditorID"],
            "like_text": "Test2",
            "min_similarity": 0.1,
            "max_query_terms": 5
        }
    }
    }

一气之下得到结果我的意思是一个对象。我也更喜欢在GET请求中指定查询no中的类型

我是弹性搜索的新手,所以请再问。

更新:我需要的是这样的东西,但这不起作用

[{
    "query": {
        "fuzzy_like_this": {
            "fields": ["user"],
            "like_text": "Haider",
            "min_similarity": 0.1,
            "max_query_terms": 5
        }
    },
    "filter": {
        "type": {
            "value": "typetest"         
        }
    }
},
{
    "query": {
        "fuzzy_like_this": {
            "fields": ["user"],
            "like_text": "Haider",
            "min_similarity": 0.1,
            "max_query_terms": 5
        }
    },
    "filter": {
        "type": {
            "value": "typetest"         
        }
    }
}

]

【问题讨论】:

    标签: types elasticsearch


    【解决方案1】:

    您可以在查询中添加过滤器并过滤_type 字段。

    有帮助吗?

    【讨论】:

    • 感谢您的重播,正如我所说我是 ES 的新手,所以您的意思是像 { "query": { "fuzzy_like_this": { "fields": ["LastEditorID"], "like_text": "C4446476-15E6-E111-9ECB-B7C5971D170A", "min_similarity": 0.1, "max_query_terms": 5 } }, "filter": { "type": { "value": "test1" } } } 这样的东西,因为那不起作用
    • 举个例子会有很大帮助
    猜你喜欢
    • 1970-01-01
    • 2018-08-15
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2011-09-28
    • 2018-10-26
    • 1970-01-01
    • 2021-11-23
    相关资源
    最近更新 更多