1

我是弹性搜索的新手,设法设置它并使用河流插件从我的 mongodb 集合中导入记录集。首先,我想查询“desc”字段,但无法获得查询..不确定问题是否由索引的定义方式驱动..有人可以帮忙吗?

弹性搜索中的示例记录集如下所示

{
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 107209,
      "max_score": 1,
      "hits": [
         {
            "_index": "shiv",
            "_type": "shiv",
            "_id": "iG1eIzN7RGO7hFfxTlnLuA",
            "_score": 1,
            "_source": {
               "_id": {
                  "$oid": "50901d7f485bf7bd1c000021"
               },
               "brand": "",
               "category": {
                  "$ref": "categories",
                  "$id": {
                     "$oid": "4fbd2221758cb11d14000174"
                  }
               },
               "comments": [],
               "count_comment": 0,
               "count_fav": 2,
               "count_hotness": 1.46,
               "count_rekick": 0,
               "count_share": 0,
               "country": {
                  "$ref": "countries",
                  "$id": {
                     "$oid": "4fec98f7758cb18c6e0002c9"
                  }
               },
               "currency": "pound",
               "desc": "A men's automatic watch, this Seamaster Bond model features a Co-Axial escapement and date function. Its blue dial is teamed with a stainless steel case and bracelet for a look that's sporty and refined.",
               "gender": "male",
               "ident": "omega-seamaster-diver-bond-men-s-automatic-watch---ernest-jones-1351622015",
               "img_url": "http://s7ondemand4.scene7.com/is/image/Signet/5735793?$detail$",
               "lifestyles": [
                  {
                     "$ref": "lifestyles",
                     "$id": {
                        "$oid": "508ff6ca485bf73112000060"
                     }
                  }
               ],
               "location": "United Kingdom",
               "owner": {
                  "$ref": "accounts",
                  "$id": {
                     "$oid": "50742fd8485bf74b7a00213f"
                  }
               },
               "price": 2400,
               "store": "ernestjones.co.uk",
               "tags": [
                  "ernest-jones",
                  "bond"
               ],
               "timestamp_creation": 1351622015,
               "timestamp_exp": 1356825600,
               "timestamp_update": 1351622015,
               "title": "Omega Seamaster Diver Bond men's automatic watch - Ernest Jones",
               "url": "http%3A%2F%2Fwww.ernestjones.co.uk%2Fwebstore%2Fd%2F5735793%2Fomega%20seamaster%20diver%20bond%20men%27s%20automatic%20watch%2F%3Futm_source%3Dgooglebase%26utm_medium%3Dfeedmanager%26cm_mmc%3DFroogle-_-CKB-_-nurses_fobs-_-watches%26cm_mmca1%3Domega%26cm_mmca2%3Dmale%26cm_mmca3%3Dadult"
            }
         }
      ]
   }
}

索引“shiv”的映射看起来像

{
   "shiv": {
      "properties": {
         "$oid": {
            "type": "string"
         }
      }
   }
}

再次感谢

4

1 回答 1

0

查询方式有很多种,你试过匹配查询吗?

使用 curl 或您选择的其他客户端...
http://[host]:9200/[index_name]/[doc_type]/_search

    {
        "query" : {
            "match" : {
                "desc" : "some value you want to find in desc"
            }
        }
    }
于 2013-10-27T19:00:13.027 回答