Introduction to Distributed Search Elasticsearch index of literature retrieval

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.