1. First, submit the following data to es to create an index.
{"Number": 32768, "Singer": "Yang Kun", "size": "5109132", "Song": "", "tag ": "Voice of China", "timelen": 319}
{"Number": 32769, "Singer": "Wang Feng", "size": "6001697", "Song": "I love you China", "tag ": "Voice of China", "timelen": 375}
{"Number": 32780, "Singer": "Wang Feng", "size": "4070469", "Song": "I love you so", "tag ": "Voice of China", "timelen": 254}
{"Number": 32796, "Singer": "", "size": "3046005", "Song": "", "tag": "Children's songs ", & quot; timelen & quot;: 190}
{"Number": 32896, "Singer": "Bandari", "size": "3869593", "Song": "The Golden Land", "tag ": "fetal music", "timelen": 241}
{"Number": 32977, "Singer": "Bandari", "size": "3477514", "Song": "childhood memory", "tag": "Europe and America ", & quot; timelen & quot;: 217}
2. elasticsearch's query DSL
The Restful API for search is
URL format: http: // ip: Port/index/type/_ search
The query statement is sent to es through post.
A. Basic full-text search
Search for records in the index library that contain "music"
{
"Query ":{
"QUERY_STRING ":{
"Query": "music"
}
}
}
B. Search by specified fields
Search for records containing China in the Song Field
{
"Query ":{
"QUERY_STRING ":{
"Query": "China ",
"Fields ":[
"Song"
]
}
}
}
C. Multi-field weight Query
Search for the keyword "China" in the song and tag fields. If the weight is 2 in the Song field, the default value is 1 in the tag field. The results show that the song name contains China, which is the top one.
{
"Query ":{
"Multi_match ":{
"Query": "China ",
"Fields ":[
"Song ^ 2 ",
"Tag"
]
}
}
}
For more detailed query syntax, see: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html
Introduction to searching elasticsearch index documents