Obenland
Obenland

Reputation: 866

Searching on flat multivalue fields

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.

Upvotes: 0

Views: 84

Answers (2)

MatsLindh
MatsLindh

Reputation: 52912

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.

Upvotes: 2

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8678

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.

Upvotes: 1

Related Questions