使用mongoDB进行Elasticsearch自动完成映射和建议

时间:2014-07-01 13:14:17

标签: elasticsearch

我遇到弹性搜索的自动完成功能问题。 它正在使用我的postgresql映射,但不是我的mongodb映射。也许是因为我的完成领域不是主要领域。

以下是映射:

{
    "mappings" : {
      "customer" : {
        "properties" : {
          "cd" : {
            "properties" : {
              "EAN" : {
                "type" : "string"
              },
              "ab" : {
                "type" : "string"
              },
              "ad3" : {
                "type" : "string"
              },
              "cc" : {
                "type" : "string"
              },
              "cit" : {
                "type" : "string"
              },
              "civ" : {
                "type" : "string"
              },
              "ctry" : {
                "type" : "string"
              },
              "dob" : {
                "type" : "string"
              },
              "ew" : {
                "type" : "long"
              },
              "fn" : {
                "type" : "string"
              },
              "lvst" : {
                "type" : "string"
              },
              "mn" : {
                "type" : "string"
              },
              "name" : {
                "type" : "completion"
              },
              "pc" : {
                "type" : "string"
              },
              "pdc" : {
                "type" : "string"
              },
              "stat" : {
                "type" : "string"
              },
              "tb" : {
                "type" : "string"
              },
              "zc" : {
                "type" : "string"
              }
            }
          },
          "cid" : {
            "type" : "string"
          },
          "off" : {
            "properties" : {
              "ol" : {
                "properties" : {
                  "cnt" : {
                    "type" : "long"
                  },
                  "desc" : {
                    "type" : "string"
                  },
                  "ed" : {
                    "type" : "string"
                  },
                  "ot" : {
                    "type" : "long"
                  },
                  "sc" : {
                    "type" : "long"
                  },
                  "sd" : {
                    "type" : "string"
                  },
                  "title" : {
                    "type" : "string"
                  }
                }
              }
            }
          },
          "rec" : {
            "properties" : {
              "rc" : {
                "type" : "long"
              },
              "rl" : {
                "type" : "long"
              }
            }
          },
          "rst" : {
            "properties" : {
              "pc" : {
                "type" : "long"
              },
              "pl" : {
                "type" : "long"
              }
            }
          },
          "sh" : {
            "properties" : {
              "cnt" : {
                "type" : "long"
              },
              "res" : {
                "type" : "string"
              },
              "ttl" : {
                "properties" : {
                  "date" : {
                    "type" : "string"
                  },
                  "pl" : {
                    "type" : "long"
                  },
                  "sta" : {
                    "type" : "long"
                  }
                }
              }
            }
          }
        }
      }
    }
  }'

这是我的疑问:

curl -X POST localhost:9200/retail_crm_demo/_suggest -d '
{
  "retail_crm_demo" : {
    "text" : "du",
    "completion" : {
      "field" : "name"
    }
  }
}'

我还有另一个问题,当一个完成类型的字段试图保存空数据时,河流会崩溃,你知道如何避免这个问题吗?

提前感谢你!!

1 个答案:

答案 0 :(得分:0)

你会解释一下,河流如何以及何时崩溃"?我可以在索引数据中存储记录:

POST /retail_crm_demo/customer
{
    "pc" : "pc1"
}

我没有问题。

相关问题