solr - How can I exclude from the result the multivalue fields that don't match my query?

659 views Asked by At

I have some indexed documents like the one above:

{
  "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 query for “ho hum” I need that the document returned 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 the exactly page that have the words i was searching for. How can i do that?

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

OBS: I am using solr-4.10.2 and a data-import (db-data-config.xml) from my SQL Server database.

1

There are 1 answers

4
MatsLindh On BEST ANSWER

You can't, at least not without a lot of manual tinkering.

Two possible solutions is to index each page as a separate document, or use the Block Join feature of Solr. The first option is probably the quickest to implement.