In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to use the function query of Solr". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Action
A function query allows us to grade a document using the value of the numeric field or a function of a specific value associated with the domain.
How to use
There are two main methods that can be queried using functions, both of which are through the solr http interface:
1. Embedded in the normal solr query expression. 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.
2. Use parameters that are specifically queried for the function, such as the parameter 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: q=dismax&bf=ord (popularity) ^ 0.5 recip (rord (price), 1Mei 1000 and 1000) ^ 0.3
Function format
At present, function query does not support the form of aforb, we have to write it in a method form, which is called sum (aforb).
Detailed explanation of function
1. Constant: constants with decimal points are supported
For example, 1.5, the query expression is: _ val_:1.5
2. Fieldvalue, this function will return the value of numeric field. 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.
3. 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 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.
4. Rord, this function will return the inverted ranking corresponding to ord.
Format: rord (myIndexedField).
5. 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)
6. Product,product. The product of multiple functions will be returned.
Format: product (xpai2)
Product (XBI y)
7. Div,div (xQuery y) represents the value of x divided by y
Format: div (1meme x)
Div (sum (xmem100), max (ymem1))
8. Pow,pow represents a power value. Pow (x ^ y) = x ^ y.
Format: pow (xpene 0.5) represents the square
Pow (XJO log (y))
9. Abs,abs (x) returns the absolute value of the expression
Format: abs (- 5)
Abs (x)
10. Log,log (x) will return a logarithm with a cardinality of 10
Format: log (x)
Log (sum (xmem100))
11. Sqrt,sqrt (x) returns the square root of a number
Format: sqrt (2)
Sqrt (sum (xmem100))
12. Map, if min
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.