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"



    
    
  • 相关阅读:
    事件驱动模型 泽桐
    装饰器 泽桐
    多用户在线FTP程序 泽桐
    gevent协程、select IO多路复用、socketserver模块 改造多用户FTP程序例子 泽桐
    mysql系列学习 泽桐
    mysql练习题 泽桐
    第1章 Python基础 泽桐
    协程 泽桐
    利用统计进行中文分词与词性分析
    js 数字输入控制,保留两位小数
  • 原文地址:https://www.cnblogs.com/minjay/p/6676958.html
Copyright © 2011-2022 走看看