Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Elasticsearch索引MongoDB“id_3;”字段?_Mongodb_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Mongodb,elasticsearch" /> elasticsearch,Mongodb,elasticsearch" />

如何使用Elasticsearch索引MongoDB“id_3;”字段?

如何使用Elasticsearch索引MongoDB“id_3;”字段?,mongodb,elasticsearch,Mongodb,elasticsearch,我正在MongoDB中使用ElasticSearch,希望在我的ElasticSearch索引中搜索ObjectId My MongoDB包含以下条目: { "_id" : ObjectId("54ca06664ceb6693d37de155"), "blabla" : "xxxyyy"} 我尝试创建自定义映射,例如: curl -XPOST "http://localhost:9200/myIndex/myType/_mapping" -d' { "myType":{ "properti

我正在MongoDB中使用ElasticSearch,希望在我的ElasticSearch索引中搜索ObjectId

My MongoDB包含以下条目:

{ "_id" : ObjectId("54ca06664ceb6693d37de155"), "blabla" : "xxxyyy"}
我尝试创建自定义映射,例如:

curl -XPOST "http://localhost:9200/myIndex/myType/_mapping" -d'
{
"myType":{
  "properties":{
    "_all": {
      "enabled": false
    },
    "_id": {
      "type": "string",
      "store": true,
      "index": "analyzed"
    },
    "blabla": {
      "type": "string",
      "store": true,
      "index": "analyzed"
    }
}
}"

但是当我想用

curl -XGET 'http://localhost:9200/_all/_mapping'
我看不到_id映射。搜索54ca06664ceb6693d37de155也不会返回任何结果


怎么了?

\u id字段是像mongoDB这样的Elasticsearch中的默认主键。虽然您找不到\u id字段的映射,但可以使用下面的查询来搜索\u id字段。更多信息

您可以在退货文档中找到_id字段:

 {
"_index" :   "website",
"_type" :    "blog",
"_id" :      "123",
"_version" : 1,
"found" :    true,
"_source" :  {
  "title": "My first blog entry",
  "text":  "Just trying this out...",
  "date":  "2014/01/01"
 }
}
问题1:

问题2:


您如何将数据从MongoDB加载到Elasticsearch?你在加载任何数据之前创建了这个映射吗?我使用的是River。首先创建索引,然后创建映射,最后创建河流。它适用于其他字段,但不幸的是不适用于id字段。
{
"query": {
    "terms": {
       "_id": [
          "VALUE1",
          "VALUE2"
       ]
    }
  }
}
{
  "query": {
    "term": {
       "_id": {
          "value": "VALUE"
          }
       }
    }
}