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

How to use solr word Segmentation query

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use solr participle query". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use solr participle query.

1 preparation for Lab 1.1

Word segmentation field: / CaseInfo/ case / @ DocContent

Word Separator: IKAnalyzer2012

Test keyword: rob gold

Return field: / CaseInfo/ case / @ DocContent

Insert 3 pieces of data separately, and insert different values into DocContent

1.2 Test

1. Query conditions: *: *

The query results are as follows:

2. Query conditions:\ / CaseInfo/ case / @ DocContent: gold robbery

The query results are as follows:

3. Query conditions:\ / CaseInfo/ case / @ DocContent: "robbing gold"

Note: the gold robbery is in quotation marks.

The query results are as follows:

4. Query conditions:\ / CaseInfo/ case / @ DocContent: robbery AND\ / CaseInfo/ case / @ DocContent: gold

The query results are as follows:

5. Query conditions:\ / CaseInfo/ case / @ DocContent: robbery OR\ / CaseInfo/ case / @ DocContent: gold

The query results are as follows:

6. Query conditions:\ / CaseInfo/ case / @ DocContent: gold robbery

Note: add a space between robbery and gold

The query result is empty:

1.3 result analysis

Since the query result is related to the query statement parsed by solr, check debugQuery in the lower left corner of the interface to get the corresponding parsedquery_ tostring value, as shown in the following table:

According to the above table, the following analysis results can be obtained.

1.3.1 *: *

The query statement indicates that all data is queried.

1.3.2\ / CaseInfo/ case / @ DocContent: gold robbery

The DocContent field that represents the query must contain "robbery" and "gold" after participle. The "+" in the parsedquery_toString value indicates that there is an operator, which requires that the item after the symbol "+" must exist in the field. After the result of word segmentation in the first table, the two data meet the requirements.

A) rob gold

B) Gold, do not rob

1.3.3\ / CaseInfo/ case / @ DocContent: "robbing gold"

Double quotation marks are added to indicate a perfect match, indicating that the DocContent field of the query must contain "robbing gold" after word segmentation. After the result of word segmentation in the first table, a piece of data meets the requirements.

A) rob gold

1.3.4\ / CaseInfo/ case / @ DocContent: robbery AND\ / CaseInfo/ case / @ DocContent: gold

AND means that both the left condition and the right condition are satisfied. After participle, the DocContent field should contain both "robbery" and "gold". Two pieces of data meet the requirements.

A) rob gold

B) Gold, do not rob

1.3.5\ / CaseInfo/ case / @ DocContent: robbery OR\ / CaseInfo/ case / @ DocContent: gold

OR means either that a condition can be satisfied. The DocContent field contains either "robbery" or "gold" after participle. Three pieces of data meet the requirements. Three results:

A) rob gold

B) Gold, do not rob

C) Sun Yellow Sun Gold robbery

1.3.6\ / CaseInfo/ case / @ DocContent: gold robbery

The query result here is empty. Analyze the parsedquery_ tostring value:

+ / CaseInfo/ case / @ DocContent: robbery + (+ text: Huang + text: gold)

Indicates that the DocContent field must contain "robbery" after participle, and the text field must contain "yellow" and "gold" to meet the condition. Since we do not want to assign a value to the text field, the result is empty in the second half of the year. Why is there a text field?

In schema.xml

In solrconfig.xml

Explicit

ten

Text

Both the defaultSearchField attribute in schema.xml and the df attribute in solrconfig.xml mean the default search field (note: defaultSearchField is annotated by default), and the priority is that the df of solrconfig.xml is higher than the defaultSearchField of schema.xml.

Set the effect of the default field. The search condition is\ / CaseInfo/ case / @ DocContent: robbing gold, and the space in the middle is equivalent to AND, so the search condition is equivalent to\ / CaseInfo/ case / @ DocContent: robbery AND text: gold, so the island results will not be searched.

Solution:

Method 1: you can change the condition to\ / CaseInfo/ case / @ DocContent: (robbing gold).

Method 2: the search condition remains unchanged, and the value of URL plus df field is / CaseInfo/ case / @ DocContent when querying.

At this point, I believe you have a deeper understanding of "solr participle query how to use", might as well to the actual operation of it! 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