Map used by solr Functions

Source: Internet
Author: User
Tags solr

The map function maps the values in the specified range of a field to the target value.

Common usage:

Map (x, min, max, target) and map (x, min, max, target, other)

For example:

Map (x, 0, 0, 1) maps the value of x in the function parameter to 1 if it is 0, which is useful when the default value is 0.

If map (x, 10,100, 10,100) falls between [] in the function parameter, the value of x is mapped to 1; otherwise, the value is mapped to 2.

 

Usage:

Generally used for sorting

 

Sort = sum (value, map (age, 10, 10, $ x, $ y) + asc & x = 2 & y = 3

 

If the value of the age field is 10, the value is mapped to 2. Otherwise, the value is 3, and the value is added, which is sorted in ascending order.

 

Sort = sum (value, map (age, 10, 10, $ x, $ y) + asc & x = sum (2, some_field * 2) & y = 3

Similar to the intention in the previous example, the x value is generated through a function.

 

The map function is used to influence the score field and sort the score.

Http://dev.aifang.com: 8487/solr/loupan/select /? Q = {! Func} map (loupan_id, 1004,1004, 1,100) & fl = *, score & sort = score + asc, loupan_id + desc

Sort by map directly in sort

 

Http://dev.aifang.com: 8487/solr/loupan/select /? Q = *: * & fl = *, score & sort = map (loupan_id, 1004,1004, 1,100) + asc

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.