程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了elasticsearch:词条查询失败大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决elasticsearch:词条查询失败?

开发过程中遇到elasticsearch:词条查询失败的问题如何解决?下面主要结合日常开发的经验,给出你关于elasticsearch:词条查询失败的解决方法建议,希望对你解决elasticsearch:词条查询失败有所启发或帮助;

您需要为此"index": "not_analyzed"工作。并且您需要为数据重新索引以使上述更改生效。

这是映射更改和一些测试数据的命令的完整列表:

PUT /merged-2016-04
{
  "mapPings": {
    "timeslot": {
      "propertIEs": {
        "FOB_IN": {
          "type": "long"
        },
        "TRIGGER_CODE": {
          "type": "long"
        },
        "FliGHT_PHASE": {
          "type": "long"
        },
        "REP16_TRIG": {
          "type": "long"
        },
        "fwot": {
          "type": "string",
          "index": "not_analyzed"
        },
        "FOB_OUT": {
          "type": "long"
        },
        "FP": {
          "type": "long"
        },
        "FLTNB": {
          "type": "string"
        },
        "Date": {
          "format": "strict_date_optional_time||epoch_millis",
          "type": "date"
        }
      }
    }
  }
}

POST /merged-2016-04/timeslot
{
  "Date": "2016-04-03T08:42:44+0000",
  "FliGHT_PHASE": 20,
  "TRIGGER_CODE": 4000,
  "fwot": "A6-APA"
}

GET merged-2016-04/_search?size=1
{
  "query": {
    "term": {
      "fwot": "A6-APA"
    }
  }
}

解决方法

我有一些文档的映射,并且查询agains条件确实失败。我不明白为什么:

"mappings":{
     "timeslot":{
            "properties":{
                 "FOB_IN":{
                        "type":"long"
                 },"TRIGGER_CODE":{
                        "type":"long"
                 },"FLIGHT_PHASE":{
                        "type":"long"
                 },"REP16_TRIG":{
                        "type":"long"
                 },"fwot":{
                        "type":"string"
                 },"FOB_OUT":{
                        "type":"long"
                 },"FP":{
                        "type":"long"
                 },"FLTNB":{
                        "type":"string"
                 },"Date":{
                        "format":"strict_date_optional_time||epoch_millis","type":"date"
                 }
            }
     }
}

TRIGGER_CODE例如,我可以对进行词条查询,效果很好

{
   "took": 1,"timed_out": false,"_shards": {
      "total": 1,"successful": 1,"failed": 0
   },"hits": {
      "total": 5,"max_score": 4.4446826,"hits": [
         {
            "_index": "merged-2016-04","_type": "timeslot","_id": "AVRS8VnirVLwfvMnwpXb","_score": 4.4446826,"_source": {
               "Date": "2016-04-03T08:42:44+0000","FLIGHT_PHASE": 20,"TRIGGER_CODE": 4000,"fwot": "A6-APA"
            }
         }
      ]
   }
}

现在 对fwot同样失败 。怎么了?

GET merged-2016-04/_search?size=1
{
    "query" : {
        "term" : { "fwot": "A6-APA"}
    }
}

{
   "took": 1,"hits": {
      "total": 0,"max_score": null,"hits": []
   }
}

大佬总结

以上是大佬教程为你收集整理的elasticsearch:词条查询失败全部内容,希望文章能够帮你解决elasticsearch:词条查询失败所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: