douye2111 2012-12-26 10:52
浏览 212
已采纳

Solr在multiValue字段中返回每个值的每个文档

I'm new to Solr and I'm wondering if the next example is possible.

Let's say I have a core with 2 fields, a string field 'name' and a multiValued field 'ids'. With doc 1:

  • Name: Tim
  • Ids: 1,2,3

and doc 2:

  • Name: Bob
  • Ids: 2,3

Now I want a query that gives me a result array with the following elements:

  • 1 Tim
  • 2 Bob
  • 2 Tim
  • 3 Bob
  • 3 Tim

So the query returns each document per value in the multiValue field, first sorted on the value in 'ids' and second sorted on the name.

You could say, just select all the documents and handle the other stuff after the query, but I have a lot of data and I only want the first 20 documents sorted and per value in the multiValued field.

I hope this is possible and someone can help me! Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dp152153 2012-12-26 11:18
    关注

    If you want the documents to be returned multiple times and sort on both the fields, you have the insert individual records for each combination.
    This is a lot of duplication of data and but presume thats the only way you can achieve it.
    You could have used Grouping feature, however it does not work on Multivalued fields.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?