HI, In my document i have data as Party value and Party Type. A single document can have multiple Party value and Party Type. For example First document will have Party value as Pramod and Party type as client. The same document will have Party value as XYZ and Party type as supplier. I need to design the schema in such a way that i am able to query all document where client=pramod. I can do this by defining two fields in solr schema as client.name and supplier.name, however the problem is the set of values for party type is not defined and new values are likely to be added in future.
Lets say i have table with 3 columns document id Party Value and Party Type. In this table i have 3 rows. 1st row Document id: 1 Party Value: Pramod Party Type: Client. 2nd row: Document id: 1 Party Value: Raj Party Type: Supplier. 3rd row Document id:2 Party Value: Pramod Party Type: Supplier. Now in this table if i use SQL its easy for me find all document with Party Value as Pramod and Party Type as Client.
I need to design solr schema so that i can do the same in Solr. If i create 2 fields in solr schema Party value and Party type both of them multi valued and try to query +Pramod +Supplier then solr will return me the first document, even though in the first document Pramod is a client and not a supplier
I think your schema is fine but your query is not specific enough. Your query should target the specific fields. So the query will look like this:
+PartyValue:Pramod +PartyType:Supplier
The Solr query documentation has more details.
There are two possible questions you could be asking here:
- Each document has one PartyValue and one PartyType. In this case, you should use Aaron's suggestion (have one field for PartyValue and one for PartyType).
Each document can has a list of PartyValue-Type pairs. In this case you will probably want a single field, but with multiValued=true. Your query will be like
+combinedField:(pramod supplier)
The reason for having them in a single field is that you don't want to find documents where any type is A and any value is B; you want to find ones which contain a type/value pair of A/B.