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

Detailed introduction of solr query syntax

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "detailed introduction of solr query syntax". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "the detailed introduction of solr query syntax"!

Query syntax

1. Match all documents: *: *

two。 Mandatory, blocked, and optional queries:

1) Mandatory: (forexample, only entry name containing the word make) that must be included in the query result

Solr/LuceneStatement:+make,+make + up, + make + up + kiss

2) prohibited: (for example, all documentsexcept those with word believe)

Solr/LuceneStatement:+make+up-kiss

3) optional:

Solr/LuceneStatement:+make+up kiss

3. Boolean operations: AND, OR, and NOT Boolean operations (must be capitalized) are similar to Mandatory, optional, and prohibited.

1) make AND up = + make + up: the operation on the left and right sides of AND is mandatory.

2) make | | up=make OR up=makeup: the operation on the left and right sides of OR is optional.

3) + make + up NOT kiss = + make + up-kiss

4) the makeAND up OR french AND Kiss cannot achieve the desired results because the operations on both sides of the AND are mandatory.

4. Subexpression query (subquery): you can use "()" to construct a subquery.

Example: (makeAND up) OR (french AND Kiss)

5. Restrictions that block queries in subexpression queries:

Example: make (- up): you can only get the query results of make; use make (- up *: *) to query make or not include the results of up.

6. Multi-field fields query: query by adding semicolons to field names (fieldName:query)

Example: entryNm:makeAND entryId:3cdc86e8e0fb4da8ab17caed42f6760c

7. Wildcard query (wildCardQuery):

1) wildcards? And *: "*" means to match any character; "?" Represents the location where the match occurs.

Example: ma?* (one position after ma matches), ma??* (two positions after ma match)

2) query characters must be lowercase: + Ma+be** can search results; + Ma+Be** has no search results.

3) the query speed is slow, especially the wildcard is in the first place: the main reason is that each term in the query field needs to be iterated to determine whether it matches; second, the matching term is added to the internal query, and when the number of terms reaches 1024, the query will fail.

4) the default wildcard cannot appear in the first place in Solr (you can modify QueryParser and set

SetAllowLeadingWildcard is true)

5) set setAllowLeadingWildcard to true.

8. Fuzzy query, similar query: not an accurate query, through the re-insertion, deletion and transformation of the query fields to achieve a higher score query solution (supported by the LevensteinDistance Algorithm algorithm).

1) General fuzzy query: example: make-believ~

2) threshold fuzzy query: you can set a query threshold for fuzzy query. The threshold is a value between 0 / 1. The higher the threshold, the higher the surface similarity. Example: make-believ~0.5, make-believ~0.8, make-believ~0.9

9. Range query (RangeQuery): Lucene supports range queries for numbers, dates, and even text. The ending range can use the "*" wildcard.

Example:

1) date range (ISO-8601 time GMT): sa_type:2AND a_begin_date: [1990-01-01T00:00:00.000Z TO 1999-12-31T24:59:99.999Z]

2) number: salary: [2000 TO *]

3) text: entryNm: [a TO a]

10. Date matching: YEAR,MONTH, DAY, DATE (synonymous with DAY) HOUR, MINUTE, SECOND, MILLISECOND, andMILLI (synonymous with MILLISECOND) can be marked as dates.

Example:

1) r_event_date: [* TO NOW-2YEAR]: 2 years ago at this time

2) r_event_date: [* TO NOW/DAY-2YEAR]: this time on the day before 2 years ago

At this point, I believe that you have a deeper understanding of the "detailed introduction of solr query syntax". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Servers

Wechat

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

12
Report