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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题