Having the following setup on Solr 6.6.2:
A collection of Solr clouds with documents with field identifiers, ContactId, Properties and startup, and a unique key for id.
There may be several documents with the same ContactId.
Each of the contact documents has text field properties containing a string of text. The property field is indexed with a division by ',' so that, for example, Properties: Green strokes.
For instance:
+----+-----------+--------------+ | ID | ContactId | Properties | +----+-----------+--------------+ | 1 | C1 | Blue,Green | | 2 | C1 | Blue,Yellow | | 3 | C2 | Green,Yellow | +----+-----------+--------------+
Now I need to find all ContactIds where Properties has "Green" and "Yellow", where it is allowed that this request matches all the documents of this ContactID. Thus, the result will be in this case C1, C2.
I tried to group the results, but still I cannot query the grouped result.
group=true&group.field=ContactId&group.query=(Green AND Yellow)&q=(Green OR Yellow)
The idea I followed was a query (q) to get all documents that are green or yellow than grouping in group.field ContactId and then group.query with AND Condition of Green AND Yellow. But that failed.
In mySql, you could only do
group_concat(Properties) as grouped
and do something like this line:
grouped LIKE '%Green%' AND grouped LIKE '%Yellow%'
How can I achieve this query on the Solr index?
Tried, as expected, with quotes and without:
intersect( search(w3, q=Properties:("Green"), fl="ContactId", sort="ContactId asc"), search(w3, q=Properties:("Yellow"), fl="ContactId", sort="ContactId asc"), on="ContactId" )
obtained from trial crossing examples:
intersect( search(w3, q=Properties:("Green" OR "Green" AND "Yellow"), fl="ContactId", sort="ContactId asc"), search(w3, q=Properties:("Yellow" OR "Green" AND "Yellow"), fl="ContactId", sort="ContactId asc"), on="ContactId" )
But still, only results appear when both properties are inside the same document, and not those where each of them is divided into several documents of the same ContactId (only C2 in this case, but not C1).