0

let say I have got a multivalued field named myfield and some documents containing some values in myfield.

Now I start a query like this:

myfield:foobar

The result will be something like this:

<doc>
  <arr name="myfield">
    <str>foobar_1</str>
    <str>foobar_2</str>
  </arr>
</doc>
<doc>
  <arr name="myfield">
    <str>foobar_3</str>
    <str>foobar_4</str>
  </arr>
</doc>

But I don't want the result to be separated by documents. I want it flat, something like this:

<arr name="myfield">
  <str>foobar_1</str>
  <str>foobar_2</str>
  <str>foobar_3</str>
  <str>foobar_4</str>
</arr>

Is this possible in some way? Any good hint for me?


Let's try to explain want I want to do:

Every document of my solr index has a list of notations (stored in multivalued field). Now I want to search and browse those notations.

I'm going to need a special scoring for the result, so I'm going to write my own QParserPlugin.

Obenland
  • 856
  • 16
  • 28

2 Answers2

2

If you just want all the terms from a field - use a facet or the terms component. Since you apparently isn't interested in the documents themselves, a facet might be what you want.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
1

I don't think this is possible from solr. Solr will always return a document as that how it is been build. As you define your document in you schema.xml.

If you want to remove the documents and get the plain result then you have to add some logic at java end to remove the doc and get only the fields.

Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
  • That's bad. Because I'll get all entrys of `myfield` of a document so I have to check again which one was hit by the search, right? – Obenland Aug 28 '15 at 11:51
  • yes and it would be hard for you to check as it does not have any id with...for example if you have 2 same values how would you identify which one is hit... – Abhijit Bashetti Aug 28 '15 at 11:54