zoukankan      html  css  js  c++  java
  • Elasticsearch笔记2

    1 搜索所有文档中还有某个字段的方法: localhost:9200/get-together/group/_search?pretty

    {
    "query": {
    "query_string": {
    "query": "elasticsearch"
    }
    }
    }

    结果为

    {
    "took": 2,
    "timed_out": false,
    "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
    },
    "hits": {
    "total": 2,
    "max_score": 1.3782532,
    "hits": [
    {
    "_index": "get-together",
    "_type": "group",
    "_id": "3",
    "_score": 1.3782532,
    "_source": {
    "name": "Elasticsearch San Francisco",
    "organizer": "Mik",
    "description": "Elasticsearch group for ES users of all knowledge levels",
    "created_on": "2012-08-07",
    "tags": [
    "elasticsearch"
    ,
    "big data"
    ,
    "lucene"
    ,
    "open source"
    ],
    "members": [
    "Lee"
    ,
    "Igor"
    ],
    "location_group": "San Francisco, California, USA"
    }
    }
    ,
    {
    "_index": "get-together",
    "_type": "group",
    "_id": "2",
    "_score": 0.10344465,
    "_source": {
    "name": "Elasticsearch Denver",
    "organizer": "Lee",
    "description": "Get together to learn more about using Elasticsearch, the applications and neat things you can do with ES!",
    "created_on": "2013-03-15",
    "tags": [
    "denver"
    ,
    "elasticsearch"
    ,
    "big data"
    ,
    "lucene"
    ,
    "solr"
    ],
    "members": [
    "Lee"
    ,
    "Mike"
    ],
    "location_group": "Denver, Colorado, USA"
    }
    }
    ]
    }
    }

    只要某个文档中还有该字段都会被查出,也可以设置 " default_field ": " name ","default_operator": "AND",and表示只有当某文档中出现搜索的完整字段才会匹配,例如 localhost:9200/get-together/group/_search?pretty

    {
    "query": {
    "query_string": {
    "query": "elasticsearch san francisco",
    "default_field": "name",
    "default_operator": "AND"
    }
    }
    }

    也可以设置为"default_operator": "OR",就是当出现elasticsearche san francisco某一个字段都会匹配被查出,另外一种可以实现该结果的查询是: "query": "name:elasticsearch AND name:san AND name:francisco"



    
    
  • 相关阅读:
    【机器学习】算法原理详细推导与实现(一):线性回归
    《0~3岁孩子的 正面管教》——备忘
    马歇尔·卢森堡《非暴力沟通》——备忘
    李笑来《财富自由之路》——备忘
    select、poll、epoll之间的区别总结[整理]
    堆和栈区别
    Linux 文件系统剖析
    Inside The C++ Object Model(五)
    Inside The C++ Object Model(四)
    Inside The C++ Object Model(三)
  • 原文地址:https://www.cnblogs.com/minjay/p/6676958.html
Copyright © 2011-2022 走看看