【问题标题】:How to create an Elasticsearch mapping with not_analyzed nested fields?如何使用 not_analyzed 嵌套字段创建 Elasticsearch 映射?
【发布时间】:2015-07-20 22:59:33
【问题描述】:

如何使用嵌套字段创建映射,其中嵌套字段未分析?

我无法确定正确的映射,请参阅下面的示例。

通过标准标记器处理被索引到taxonomyHMG.0、taxonomyHMG.1、taxonomyHMG.2等字段的数据(可以通过运行方面查询进行测试)。

尽管所有嵌套字段都设置为“not_analyzed”,但仍会发生这种情况。我正在运行 ES 1.4.5。我错过了什么?

        "taxonomyHMG": {
                "properties": {
                "level0": {
                    "type": "string","index": "not_analyzed"
                },
                "level1": {
                    "type": "string","index": "not_analyzed"
                },
                "level2": {
                    "type": "string","index": "not_analyzed"
                },
                "level3": {
                    "type": "string","index": "not_analyzed"
                },
                "level4": {
                    "type": "string","index": "not_analyzed"
                },
                "level5": {
                    "type": "string","index": "not_analyzed"
                }
                }

更新 7.20.15 都解决了。问题是由简单的错字引起的:-)

谢谢安德烈

【问题讨论】:

  • 您正在针对新索引进行测试?
  • 您能否向我们展示您正在编制索引的示例文档?

标签: elasticsearch


【解决方案1】:

我认为您没有正确检查这一点,因为您的映射看起来不错,被索引的文档看起来不错。

我将如何检查它是这样的:

GET /hmgshopmonitor/items/_search
{
  "query": {
    "nested": {
      "path": "taxonomyHMG",
      "query": {
        "term": {
          "taxonomyHMG.0": {
            "value": "Pullover & Strick"
          }
        }
      }
    }
  }
}

【讨论】:

  • 我添加了一个测试查询加上我得到的结果......这真的很奇怪。似乎一旦嵌套了一个值,“not_analyzed”指令就会被忽略。
  • 试试这个查询,告诉我你得到了什么:{ "facets": { "termssss": { "terms": { "field": "level0", "size": 50, "order": "count" }, "nested":"taxonomyHMG" } }, "size": 0 }
  • { "error" : "SearchPhaseExecutionException [未能执行阶段 [query_fetch],所有分片失败;shardFailures {[CUrkWvbAQyC2aFL3NcCJiQ][hmgzanoxmonitor][0]: SearchParseException[[hmgzanoxmonitor][0]: from [-1],size[-1]: 解析失败 [解析源失败 [{ \"facets\": { \"termssss\": { \"terms\": { \"field\": \"level0 \", \"size\": 50, \"order\": \"count\" }, \"nested\":\"taxonomyHMG\" } }, \"size\": 0 }]]];嵌套:SearchParseException[[hmgzanoxmonitor][0]: from[-1],size[-1]: Parse Failure [facet nested path [taxonomyHMG] is not nested]]; }]", "status" : 400 }跨度>
  • 好的。尝试您的查询(来自 kibana 的查询),但也要使用类型:curl -XGET 'http://localhost:9200/hmgzanoxmonitor/items/_search?pretty 或调用类型(在您的示例中为 items)。
  • 做到了。它仍然返回小写的、已分析的术语。我还再次检查了映射。它肯定设置为 not_analyzed。 {“took”:1,“timed_out”:false,“_shards”:{“total”:1,“successful”:1,“failed”:0},“hits”:{“total”:153,“max_score “:0.0,“命中”:[]},“方面”:{“条款”:{“_type”:“条款”,“缺失”:3,“总计”:187,“其他”:0,“条款" : [ { "term" : "damen", "count" : 70 } 等
猜你喜欢
  • 1970-01-01
  • 2016-07-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多