16.validate_api
生活随笔
收集整理的這篇文章主要介紹了
16.validate_api
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
這個用來對昂貴的操作做評估使用,不會執行相應的搜索
PUT twitter/_bulk?refresh {"index":{"_id":1}} {"user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch"} {"index":{"_id":2}} {"user" : "kimchi", "post_date" : "2009-11-15T14:12:13", "message" : "My username is similar to @kimchy!"} GET twitter/_validate/query?q=user:foo返回 {"valid":true,"_shards":{"total":1,"successful":1,"failed":0}}可以攜帶的參數
1.df: default field在沒有明確說明針對哪個field的時候使用的field
2.analyzer:使用的analyzer
3.default_operator: 使用的邏輯運算符默認是or
4.lenient: 寬容,默認為false,設置為true的話如果格式不正確的話會報錯
5.analyze_wildcard: 對通配符查詢或者前綴查詢進行分詞
如果是驗證失敗
GET twitter/_validate/query {"query": {"query_string": {"query": "post_date:foo","lenient": false}} }{"valid":false,"_shards":{"total":1,"successful":1,"failed":0}}可以加一個explain來看看原因
GET twitter/_validate/query?explain=true {"query": {"query_string": {"query": "post_date:foo","lenient": false}} }返回
{"valid" : false,"_shards" : {"total" : 1,"successful" : 1,"failed" : 0},"explanations" : [ {"index" : "twitter","valid" : false,"error" : "twitter/IAEc2nIXSSunQA_suI0MLw] QueryShardException[failed to create query:...failed to parse date field [foo]"} ] }還可以加一個rewrite參數來看到lucene層面的原因
GET twitter/_validate/query?rewrite=true {"query": {"more_like_this": {"like": {"_id": "2"},"boost_terms": 1}} }{"valid": true,"_shards": {"total": 1,"successful": 1,"failed": 0},"explanations": [{"index": "twitter","valid": true,"explanation": "((user:terminator^3.71334 plot:future^2.763601 plot:human^2.8415773 plot:sarah^3.4193945 plot:kyle^3.8244398 plot:cyborg^3.9177752 plot:connor^4.040236 plot:reese^4.7133346 ... )~6) -ConstantScore(_id:2)) #(ConstantScore(_type:_doc))^0.0"}] }總結
以上是生活随笔為你收集整理的16.validate_api的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 15.profile-api
- 下一篇: 17.explain_api