ElasticSearch常用コマンド(一)——添削添削チェックコマンド

3025 ワード

1、索引の追加
curl -H "Content-Type:application/json;charset=utf-8"  -XPUT 'http://127.0.0.1:9200/test_0527'
2、mappingを追加
typeは「text」タイプのフィールドです。
text:単語を区切られ、索引を行い、あいまいな検索をサポートします。集約はサポートされていません。全文検索に適用されます。
keyword:分詞を行わず、直接索引を行う。正確なクエリー;集約支援(キーワード検索に適用)
curl -H "Content-Type:application/json;charset=utf-8" -XPOST 'http://127.0.0.1:9200/test_0527/doc/_mapping?' -d '{"doc":{"date_detection":false,"properties":{
"name":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},
"mobile_phone":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}
}}}'
3、mappingを調べる
curl -H "Content-Type:application/json;charset=utf-8" -XGET 'http://127.0.0.1:9200/test_0527/_mapping?pretty'
4、文書を挿入する
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST  'http://127.0.0.1:9200/test_0527/doc?' -d 
'{"name":"  ","mobile_phone":"13522335566"}'
5、クエリードキュメント
//     
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST  'http://127.0.0.1:9200/test_0527/doc/_search?pretty'

//           
curl -H "Content-Type:application/json;charset=utf-8" -POST 'http://127.0.0.1:9200/test_0527/_search?pretty' -d '{"_source": ["mobile_phone"]}'

//     ,      
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST 'http://127.0.0.1:9200/test_0527/_search?pretty' -d '{"query":{"match_phrase":{"name":"  "}}}'

//     ,term    
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST  'http://127.0.0.1:9200/test_0527/doc/_search?' -d  '{"query":{"term":{"mobile_phone.keyword":"13522335566"}}}'

//     ,    
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST 'http://127.0.0.1:9200/test_0527/_search?pretty' -d '{"query":{"match":{"name":" "}}}'
6、文書を削除する
curl -H "Content-Type:application/json;charset=utf-8"  -XDELETE  'http://127.0.0.1:9200/test_0527/doc/zo30-GoByqlpGcLNsU9t?'
7、索引にエイリアスを追加する
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST 'http://127.0.0.1:9200/_aliases' -d '{"actions": [{"add":{"index":"test_0527", "alias":"test"}}]}'
8、索引のあるフィールドに存在するドキュメントを検索します。
curl -H "Content-Type:application/json;charset=utf-8"  -XPOST 'http://127.0.0.1:9200/test_0527/_search?pretty' -d '{"query":{"exists" : {"field": "mobile_phone"}}}'