【问题标题】:Elasticsearch term facet not showing negative termsElasticsearch 术语方面未显示负面术语
【发布时间】:2013-03-26 12:59:09
【问题描述】:

我正在使用弹性搜索词构面,我的字段包含一些负值,但构面忽略了负号

下面是分面查询

http://myserver.com:9200/index/type/_search

获取/发布正文

{
  "facets" : {
    "school.id" : {
      "terms" : {
        "field" : "school.id",
        "size" : 10
      }
    }
  }
}

回应

{
    "took": 281,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "facets": {
        "school.id": {
            "_type": "terms",
            "missing": 302,
            "total": 4390,
            "other": 0,
            "terms": [
                {
                    "term": "1113515007867355135",
                    "count": 4390
                }
            ]
        }
    }
}

id 的实际值为-1113515007867355135,是我做错了什么还是需要传递任何东西来包含负号(词干问题)?

【问题讨论】:

标签: elasticsearch faceted-search facet


【解决方案1】:

负号是 Lucene(和 ElasticSearch)中的特殊字符。

在索引和搜索时,您需要escape it

尝试在索引中的 - 字符之前添加一个 \,这也应该在构面中显示它。

【讨论】:

  • 感谢您的链接,但它在没有 -ve 符号的方面结果中出现,在哪里为方面添加转义(查询正文)?
  • 即使在创建索引时也需要转义。 IE。在将值存储在弹性搜索索引中之前,需要对这些值进行转义。
  • 在搜索查询中的负号之前添加一个 \ 解决了我的问题。谢谢!
【解决方案2】:

Elasticsearch Google Group 得到答案。需要更新字段的映射

可能的解决方案:

更新映射并使用

"index":"analyzed","analyzer" : "keyword"

"index": "not_analyzed"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-09
    • 1970-01-01
    相关资源
    最近更新 更多