首页 > 其他 > 详细

创建索引并进行查询

时间:2017-08-07 12:31:27      阅读:305      评论:0      收藏:0      [点我收藏+]
curl -XPUT http://localhost:9200/suoyin1



curl -XPOST http://localhost:9200/suoyin1/fulltext/_mapping -d{
    "fulltext": {
             "_all": {
            "analyzer": "ik_max_word",
            "search_analyzer": "ik_max_word",
            "term_vector": "no",
            "store": "false"
        },
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word",
                "include_in_all": "true",
                "boost": 8
            }
        }
    }
}

curl -XPOST http://localhost:9200/suoyin1/fulltext/1 -d{
    "first_name" : "John1",
    "last_name" :  "Smith1",
    "age" :        251,
    "about" :      "I love to go rock climbing1",
    "interests": [ "sports", "music1" ]
}


curl -XPOST http://localhost:9200/suoyin1/fulltext/2 -d{
    "first_name" :  "Jane1",
    "last_name" :   "Smith1",
    "age" :         321,
    "about" :       "I like to collect rock albums1",
    "interests":  [ "music1" ]
}
curl -XPOST http://localhost:9200/suoyin1/fulltext/3 -d{
    "first_name" :  "Douglas1",
    "last_name" :   "Fir1",
    "age" :         351,
    "about":        "I like to build cabinets1",
    "interests":  [ "forestry1" ]
}




curl -XPOST http://localhost:9200/suoyin/fulltext/_search  -d{
  "query": {
    "match": {
      "last_name": "smith"
    }
  }
}dsl 语句查询

http://localhost:9200/suoyin/fulltext/
{
    "query" : {
        "match" : {
            "last_name" : "Smith"
        }
    }
}

 

 

suoyin1:索引名称,相当于数据库
fulltext:文档的类型

1,2,3:员工的ID
 

 

创建索引并进行查询

原文:http://www.cnblogs.com/wangchuanfu/p/7298478.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!