【问题标题】:Double wildcard in query causes weird highlighting for plain/fast vectors elasticsearch highlighters查询中的双通配符导致普通/快速向量弹性搜索荧光笔的奇怪突出显示
【发布时间】:2016-07-17 05:01:38
【问题描述】:

我正在开发弹性搜索 1.5.2

索引以下映射后:

PUT http://localhost:9200/index/_mapping/sometype
{
    "properties" : {
        "sometext" : {
            "type" : "string",
            "term_vector" : "with_positions_offsets"
        }
    }
}

和数据:

POST http://localhost:9200/index/sometype
{
    "sometext" : "A supervisor is responsible for the productivity and actions of a small group of employees. The supervisor has several manager-like roles, responsibilities, and powers. Two of the key differences between a supervisor and a manager are (1) the supervisor does not typically have hire and fire authority, and (2) the supervisor does not have budget authority."
}

用户正在尝试查找所有文档,但他键入了一个通配符:

POST http://localhost:9200/index/sometype/_search
{
    "query" : {
        "query_string" : {
            "query" : "**",
            "fields" : ["sometext"]
        }
    },
    "highlight" : {
        "pre_tags" : ["<em>"],
        "post_tags" : ["</em>"],
        "order" : "score",
        "require_field_match" : true,
        "fields" : {
            sometext : {
                "fragment_size" : 150,
                "number_of_fragments" : 1
            }
        }
    }
}

并得到以下亮点:

"highlight" : {
    "sometext" : ["responsibilities, <em>and</em> <em>powers</em>. <em>Two</em> <em>of</em> <em>the</em> <em>key</em> <em>differences</em> <em>between</em> <em>a</em> <em>supervisor</em> <em>and</em> <em>a</em> <em>manager</em> <em>are</em> (<em>1</em>) <em>the</em> <em>supervisor</em> <em>does</em> <em>not</em> <em>typically</em> <em>have</em> <em>hire</em> <em>and</em> <em>fire</em> <em>authority</em>, and"]
}

查询*?产生相同的突出显示结果 但是当查询只包含一个星号时 - 荧光笔没有返回任何内容。

在普通荧光笔上(我刚刚添加了"type" : "plain"以突出显示)结果看起来有点不同(但仍然很奇怪):

"highlight" : {
    "sometext" : [", <em>responsibilities</em>, <em>and</em> <em>powers</em>. <em>Two</em> <em>of</em> <em>the</em> <em>key</em> <em>differences</em> <em>between</em> <em>a</em> <em>supervisor</em> <em>and</em> <em>a</em> <em>manager</em> <em>are</em> (<em>1</em>) <em>the</em> <em>supervisor</em> <em>does</em> <em>not</em> <em>typically</em> <em>have</em> <em>hire</em> <em>and</em> <em>fire</em> <em>authority</em>, <em>and</em> (<em>2</em>) <em>the</em> <em>supervisor</em> <em>does</em> <em>not</em> <em>have</em> <em>budget</em> <em>authority</em>."]
}

有人知道这种行为的原因是什么吗? 也许像***? 这样的查询有什么特殊含义? 非常感谢。

【问题讨论】:

  • 刚刚检查了最新的 elasticsearch (v2.2.1) - 行为完全相同

标签: elasticsearch highlighting


【解决方案1】:
【解决方案2】:
POST /index/sometype/_search
{
"query" : {
"query_string" : {`enter code here`
"query" : "**",
"fields" : ["sometext"]
}
},
"highlight" : {
"pre_tags" : ["<em>"],
"post_tags" : ["</em>"],
"order" : "score",
"require_field_match" : true,
"fields" : {
"sometext" : {
"fragment_size" : 180,
"number_of_fragments" : 1
}
}
}
}

:=>we can use this query

【讨论】:

    猜你喜欢
    • 2014-09-17
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 2012-10-10
    • 2011-06-13
    • 2019-03-08
    • 2022-12-28
    • 1970-01-01
    相关资源
    最近更新 更多