ElasticSearch Java Rest 客户端示例
ElasticSearch Java Rest Client Examples
POST http://127.0.0.1:9200/news/_search?q=李克强
{
"query" : {
match_all:{}
},
"highlight" : {
"pre_tags" : ["", "", ""],
"post_tags" : ["", "", ""],
"fields" : [
{"title" : {}},
{"content" : {
"fragment_size" : 350,
"number_of_fragments" : 3,
"no_match_size": 150
}}
]
}
}POST http://127.0.0.1:9200/news/_search?q=李克强
{
"query" : {
match_all:{}
},
"highlight" : {
"pre_tags" : [""],
"post_tags" : [""],
"fields" : [
{"title" : {}},
{"content" : {
"fragment_size" : 350,
"number_of_fragments" : 3,
"no_match_size": 150
}}
]
}
}https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
DELETE http://127.0.0.1:9200/newshttps://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
PUT http://127.0.0.1:9200/newshttps://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
PUT /{index}/_mapping/{type}PUT http://127.0.0.1:9200/news/_mapping/article
{
"article": {
"properties": {
"pubdate": {
"type": "date",
"format": "dateOptionalTime"
},
"author": {
"type": "string"
},
"content": {
"type": "string"
},
"id": {
"type": "long"
},
"source": {
"type": "string"
},
"title": {
"type": "string"
},
"url": {
"type": "string"
}
}
}
}https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html
GET http://127.0.0.1:9200/_all/_mapping
GET http://127.0.0.1:9200/_mappingGET http://127.0.0.1:9200/news/_mapping/article输出:
…https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-mapping.html
[DELETE] /{index}/{type}
[DELETE] /{index}/{type}/_mapping
[DELETE] /{index}/_mapping/{type}DELETE http://127.0.0.1:9200/news/_mapping/articlehttp://127.0.0.1:9200/news/_analyze?analyzer=ansj_index&text=习近平
http://127.0.0.1:9200/news/_analyze?analyzer=ansj_index&text=我是中国人
http://127.0.0.1:9200/news/_search?q=习近平&analyzer=ansj_index&size=50
http://127.0.0.1:9200/news/_search?q=content:江泽民&analyzer=ansj_index&size=50
http://127.0.0.1:9200/news/_search?q=title:江泽民&analyzer=ansj_index&size=50
http://127.0.0.1:9200/news/_search?q=source:新华网&analyzer=ansj_index&size=50
ansj_index为在elasticsearch.yml文件中配置的ansj分词器…暂无开放 Issues,或尚未同步最近议题。