0
votes

I have one question about solr query that it have two multivalued fields. Fllow it is part of schema:

<field name="attribute" type="text" indexed="true" stored="true" multiValued="true"/>
<field name="locale" type="text" indexed="true" stored="true" multiValued="true"/>

It read data from a xml:

  <docs>
    <doc>
        <id>01000</id>
        <name>product1</name>
        <price>102.5</price>        
        <attributes name="description">
          <str attribute="this is english description" locale="en_US" />
          <str attribute="this is chinese description" locale="zh_CN" />
        </attributes>
    </doc>
  </docs>

The issues is that query condition either "q=attribute:english AND locale:en_US" or "q=attribute:english AND locale:zh_CN" can return this doc.

I hope only when condition is "q=attribute:english AND locale:en_US" or "q=attribute:chinese AND locale:zh_CN" that can return the doc ,how can i do it?

Thank you!

1
I don´t think you can do this with multivalued fields. I suppose you need to seperate the fields for your issueChristian Lendel

1 Answers

1
votes

The option that Christian Lendel suggested would work, the other option would be joining attribute and locale options and index it as one string: "en_US this is english description". Then you can query is like that:

q=attribute:(english en_US)

Solution might be even simpler or more complex, depends what do you want to achieve.