当前位置:网站首页>Lucene query syntax memo

Lucene query syntax memo

2022-07-28 10:38:00 Two dogs don't run

Syntax reference :

​https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax​

​https://lucene.apache.org/core/9_2_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description​

 Simple query example :
#  Full text search  Exception
Exception

#  Specify query fields  message  Inside  Exception
message: Exception

#  Search for phrases 
message: "java.lang.NullPointerException"

#  whatever  message  The fields all contain  Exception
message\*: Exception

#  The use of wildcards ,?  Instead of a single character ,*  Replace zero or more characters 
message: Exceptio*

#  Regular expressions are expressed by using  /  Surround , It can be embedded in the query string 
message: /Ex?(cep[tion])/

#  Another regular use , Match means 「 Two non abc Any character of 」
info.recallId: /[^abc]{2}/


 Examples of complex queries :
#  Support  AND, OR, NOT, Or you could write it as &&, ||, ! The operator 
message: ((Exception AND Error) OR (Error AND Exception) OR Error) AND NOT Exception

#  contain  lucene  But does not contain  elasticsearch
lucene NOT elasticsearch

# +  Must contain , Others are optional ,lucene  Must contain ,apache  not essential ...
+lucene apache

#  Operation symbols that cannot appear "-", Contains  lucence, But does not contain  apache...
+lucene-apache    


 Range query example :
# [min TO max]  It's a closed interval 
# {min TO max}  It's open range 
@timestamp: [1510536210000 TO 1510550000000]
# *  Indicates that there is no limit on one end 
count:[10 TO *]


 Escape query example ::
#  Example 
message: "domain\=jobmd_ent4ent" 
#  Escape character 
+-=&&||><!(){}[]^"~*?:\/


 Fuzzy query example :
# mastering book Elasticsearch  It will also be considered a match 
title: "mastering Elasticsearch"~2

Ref: ​​http://onsole.hsk.oray.com/forward​

原网站

版权声明
本文为[Two dogs don't run]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280958249383.html