2013-03-26 52 views
2

我使用弹性搜索词方面,我的字段包含一些负值,但小无视以下的负号Elasticsearch长期方面没有表现出消极方面

是小查询

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

GET/POST体

{ 
    "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,我是不是做错了什么或者我需要通过什么包括负号(所产生的问题)?

+0

张贴在elasticsearch group https://groups.google.com/forum/#!topic/elasticsearch/FeObbeT1eok – mtariq 2013-03-26 18:09:31

回答

1

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

可能的解决方案:

更新的映射和使用

“指数”: “分析”, “分析”: “关键词”

“指数”: “not_analyzed”

2

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

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

尝试在索引中的-字符之前添加一个\,这也应该将其纳入方面。

+0

感谢您的链接,但它在facet结果中没有-ve标志,在哪里添加转义facet(查询主体)? – mtariq 2013-03-26 17:09:43

+0

即使在创建索引时也需要转义。即在将这些值存储在弹性搜索索引中之前,这些值需要被转义。 – 2013-03-27 00:45:29

+0

在搜索查询中的负号之前添加\解决了我的问题。谢谢! – 2014-04-30 10:42:03