1, first, for example, the following data is submitted to ES that index
{"Number": 32768, "singer": "Yang Kun", "Size": "5109132", "Song": "20 years old Tonight", "tag": "China good Voice", "Timelen": 319}
{"Number": 32769, "singer": "Wang Feng", "Size": "6001697", "song": "I Love You China", "tag": "China good Voice", "Timelen": 375}
{"Number": 32780, "singer": "Wang Feng", "Size": "4070469", "song": "I Love You So", "tag": "China Good Sound", "Timelen": 254}
{"Number": 32796, "singer": "Big Miss", "size": "3046005", "Song": "Adult", "tag": "Nursery Song", "Timelen": 190}
{"Number": 32896, "singer": "Bandari", "Size": "3869593", "Song": "The Golden Land", "tag": "Prenatal Music", "Timelen": 241}
{"Number": 32977, "singer": "Bandari", "Size": "3477514", "Song": "Childhood Memory", "tag": "Europe and America", "Timelen": 217}
2. ElasticSearch ' s query DSL
The restful interface of the search is _search
URL form: Http://ip:port/index/type/_search
Query queries are sent to ES via post.
A, the main full-text search
Find records that include "music" in the Index library
{
"Query": {
"Query_string": {
"Query": "Music"
}
}
}
Bspecifying fields for retrieval
Find records in song field that contain China
{
"Query": {
"Query_string": {
"Query": "China",
"Fields": [
"Song"
]
}
}
}
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvz2r1dgxpdxl1bjgynw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast ">
c, multi-field weight query
Search for keyword "China" in song and tag two fields, assuming the weight is 2 in the song field. The default is 1 in the tag.
Through the results can see the song name contains China is ranked in front.
{
"Query": {
"Multi_match": {
"Query": "China",
"Fields": [
"Song^2",
"Tag"
]
}
}
}
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvz2r1dgxpdxl1bjgynw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast ">
Many other specific query syntaxes can be tested: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Introduction to Distributed Search Elasticsearch index of literature retrieval