I have a Solr core representing employees. The schema includes these fields
- id: long values stored and indexed
- text: a catch-all text index constructed from employee name and other text but NOT the id field
In the index, there is an employee named "Anssi Törmä" (name indexed) with id 40764.
My goal is to dynamically, using Criteria, build a SolrQuery query that finds employees where the text contains words starting with given keywords OR, if a keyword is a number, employees with ID in the set input numbers.
From keywords "anssi" and "40764" my code builds criterion that is the same as
I expect that the criterion would find the above-mentioned person because although the text does not match (does not contain the ID), the ID search does match.
I can see that the query built from the criteria is translated to the Solr query text:anssi* AND text:40764* OR id:40764. However, that query does not return any results, apparently because it doesn't have the correct parenthesization. A query that produces the expected results is ((text:anssi* AND text:40764*) OR id:40764).