apache-solr – How can I exclude from the result the multivalue fields that do not match my query?

Question:

I have some documents indexed like the one below:

{
  "doc_desc": "Indexing Child Documents in JSON",
  "doc_id": "379",
  "image_id": [
          "28086# ho hum... this is page 1 of chapter 1",
          "28087# more text... this is page 2 of chapter 1",
          "28088# more text... this is page 3 of chapter 1"
      ]
}

When I search for "ho hum", I need the document returned to be something like:

{
      "doc_desc": "Indexing Child Documents in JSON",
      "doc_id": "379",
      "image_id": [
              "28086# ho hum... this is page 1 of chapter 1"
       ]
}

So I can know exactly which page contains the words I was looking for. How can I do this?

In other words… How do I exclude from the result the multivalue fields that don't match my query?

NOTE: solr-4.10.2 and a data-import (db-data-config.xml) from my SQL Server database.

Answer:

There's been an open ticket in Solr's JIRA since 2012 for the development of this functionality, but it's still open and unresolved.

Solr: Return only matched multiValued field

For now this is not yet possible to do with native Solr.

Scroll to Top