solr sub facet排序不使用派生字段的查询

时间:2017-05-05 09:22:24

标签: solr

我需要获得2个方面,如果可能的话,我可以划分2个方面值并得到派生字段并对其进行排序,

比较的简单工作示例:

 const jsonFacet = { // json facet for counts
    users: {
      type: 'terms',
      field: 'job_type_id',
      limit: 30,
      sort: 'div(expected/current)',
      facet: {
        expected: 'sum(expected_salary)',
        current: 'sum(current_salary)',
      },
    },
  };

工作示例的输出

facets: {
    count: 857,
      users: {
      buckets: [
        {
          val: 1737,
          count: 623,
          expected: 10449,
          current: 10449,
        },
        {
          val: 3387,
          count: 149,
          expected: 10449,
          current: 10449,
        },
        {
          val: 3189,
          count: 85,
          expected: 10449,
          current: 10449,
        }
      ]
    }
  }

我的示例 - 哪个无效,当我为方面添加查询时,我无法使用或者我无法找到任何文档div()

 const jsonFacet = { // json facet for counts
        users: {
          type: 'terms',
          field: 'job_type_id',
          limit: 30,
          sort: 'div(expected.count,current.count)', // issues here
          facet: {
            expected: {
              query: 'state_id:(4 5 8 9 10)',
            },
            current: {
              query: 'state_id:(2 3 4 5 8 9)',
            }
          },
        },
      };

有问题的查询输出,如果我不添加sort,那么我将得到以下结果。如果我启用排序(我没有在任何地方获取文档,以我自己的方式尝试)然后我得到error":{"trace":"java.lang.NullPointerException\n

facets: {
    count: 857,
      users: {
      buckets: [
        {
          val: 1737,
          count: 623,
          shortlist_ratio_num: {
            count: 337
          },
          shortlist_ratio_den: {
            count: 452
          }
        },
        {
          val: 3387,
          count: 149,
          shortlist_ratio_num: {
            count: 31
          },
          shortlist_ratio_den: {
            count: 56
          }
        },
        {
          val: 3189,
          count: 85,
          shortlist_ratio_num: {
            count: 29
          },
          shortlist_ratio_den: {
            count: 56
          }
        }
      ]
    }
  }

0 个答案:

没有答案
相关问题