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 functionQuery in solr

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Today, I will talk to you about how to use functionQuery in solr. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

How to use function query

There are two main ways to query using functions, both of which are through the solr http interface.

Embedded in normal solr query expressions. That is, write the function query in the parameter Q, and at this time, we use _ val_ to distinguish the function from other queries. As for how to use it, please pay attention to the following examples.

Use parameters that are specifically queried for the function, such as bf (boost function) in dismax. Note: the parameter bf can be queried by multiple functions, separated by spaces, and can be weighted. Therefore, when we use the parameter bf, we must ensure that there are no spaces in a single function, otherwise the program may think it is two functions.

For example: "ord (popularity) ^ 0.5 recip (rord (price), 1meme 1000) ^ 0.3"

Format of the function (Function Query Syntax)

At present, function query does not support the form of aforb, we have to write it as a method form, which is called sum (amemb).

Available functions (available function) constant

Support for constants with decimal points

For example: 1.5

SolrQuerySyntax:_val_:1.5

Fieldvalue

This function will return the value of numeric field, and the field must be indexd, not multiValued. The format is simple, which is the name of the domain. If there is no such value in this field, 0 will be returned.

Ord

For a field, all its values will be arranged in dictionary order, and this function returns the ranking of the specific values you want to query in this order. This field, which must be non-multiValued, returns 0. 0 when no value exists.

For example: a particular field can only go to three values, "apple", "banana", "pear", then ord ("apple") = 1 banana ("banana") = 2 ("pear") = 3.

It is important to note that the function ord () depends on the position of the value in the index, so the value of ord () changes when a document is deleted or added. When you use MultiSearcher, this value is variable.

Rord

This function will return the inverted ranking corresponding to ord.

Format: rord (myIndexedField).

Sum

The meaning of this function is obvious, it means "and".

Format: sum (xprimel)

Sum (XBI y)

Sum (sqrt (x), log (y), zpene 0.5)

Product

Product (xmeme ypas...) The product of multiple functions will be returned.

Format: product (xpai2)

Product (XBI y)

Div

Div represents the value of x divided by y

Format: div (1meme x)

Div (sum (xmem100), max (ymem1))

Pow

Pow represents a power value. Pow (x ^ y) = x ^ y.

For example, pow (x _ (0.5)) indicates the square.

Pow (XJO log (y))

Abs

Abs (x) returns the absolute value of the expression

Format: abs (- 5)

Format: abs (x)

Log

Log (x) will return a logarithm with a cardinality of 10

Format: log (x)

Log (sum (xmem100))

Sqrt

Sqrt (x) returns the square root of a number

Format: sqrt (2)

Sqrt (sum (xmem100))

Map

If x > = min, and x = 0, the maximum value of this function is 1, and the size of the value decreases as x increases.

For example: recip (rord (creationDate), 1mem1000 and 1000)

Max

Max (XQuery c) will return the maximum value between a function and a constant.

For example: max (myfield,0)

After reading the above, do you have any further understanding of how to use functionQuery in solr? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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