Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

ElasticSearch Note arrangement (4): ElasticSearch Rest and Settings, M

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

[toc]

ElasticSearch Restcurl-XGET 'http://uplooking01:9200/bank/_search?q=*&pretty'curl-XPOST' http://uplooking01:9200/bank/_search?pretty'-d' {"query": {"match_all": {}}'-- -on the basis of at least Just two results: curl-XGET 'http://uplooking01:9200/bank/_search?q=*&pretty&from=0&size=2'curl-XPOST' http://uplooking01:9200/bank/_search?pretty'-d' {"query": {"match_all": {}}, from: 0 Size: 2}'- sort curl-XPOST 'http://uplooking01:9200/bank/_search?pretty'-d' {"query": {"match_all": {}}, from: 0, size: 2 "sort": {"balance": {"order": "desc"}}'- how do I get the returned field curl-XGET 'http://uplooking01:9200/bank/_search?_source=age,balance&pretty&from=0&size=2'post? Curl-XPOST 'http://uplooking01:9200/bank/_search?pretty'-d' {"query": {"match_all": {}}, from: 0, size: 2, "sort": {"balance": {"order": "desc"}}, "_ source": ["balance" "age"]}'--match: specific matching operation curl-XPOST 'http://uplooking01:9200/bank/_search?pretty'-d' {"query": {"match": {"age": 20}}, "from": 0 "size": 2, "sort": {"balance": {"order": "desc"}}, "_ source": ["balance" "age"]}'- boolcurl-XPOST 'http://uplooking01:9200/bank/_search?pretty'-d' {"query": {"bool": {"should": [ {"match": {"age": 20}} {"match": {"gender": "F"}, "from": 0, "size": 2, "sort": {"balance": {"order": "desc"}}, "_ source": ["balance" "age"]}'{"query": {"bool": {"should": {"match": {"age": 20}}, "should": {"match": {"gender": "F"}, "sort": {"age": {"order": "asc"}, "_ source": ["balance" "age" "gender"]} both of the above methods can be used-filter query curl-XPOST 'http://uplooking01:9200/bank/_search?pretty'-data' { "query": {"filtered": {"query": {"match_all": {}} "filter": {"range": {"balance": {"gte": 20000 "lte": 30000} 'query data with revenue between 20000 and 30000 Settings, MappingsSettings maintenance index database default configuration Of course, it is often used to modify the default configuration. For example: number of fragments Number of copies view: index that does not exist for curl-XGET http://localhost:9200/bigdata/_settings?pretty operation: curl-XPUT 'localhost:9200/bigdata/'-d' {"settings": {"number_of_shards": 3 "number_of_replicas": 2}} 'operation existing index: curl-XPUT' localhost:9200/bigdata/_settings'-d' {"index": {"number_of_replicas": 2}} 'Mappings defines the field name and data type of the index in the index database. Similar to defining field names and their data types when tables are created in a relational database (similar to schme in solr), but es's mapping is much more flexible than the database, which can add fields dynamically. Generally speaking, you do not need to specify mapping, because es will automatically define its type according to the data format. If you need to add special attributes to some fields (such as defining the use of other word splitters, whether to segment words, whether to store, etc.), you must manually add the mapping information of the mapping query index database curl-XGET http://localhost:9200/bigdata/dep/_mapping?prettymappings to modify the field-related properties. See remarks for example: field type, which word segmentation tool to use mappings Note: below, you can use indexAnalyzer to define a word splitter, or you can use index_analyzer to define a word splitter.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report