I'd like to query a string to Solr and let it answer with all records which are a subset of that string.

The string is separated by comma. I wanna make solr to give me all records where a specific string field is a subset of the string provide as the request .


Imagine I have an string field indexed in Solr which is a set of string separated by comma. For example, let's say I have the following record's field indexed in Solr:









I wanna Solr to receive a query with, for example, "AAA, AAD" and reply with the following records:




If I query by "AAA, AAB, AAC" the retrieved records would be...





The retrieved records must be exactly a subset of the string provided

Is it possible to make Solr behave like this?

  • Hi Meenu, in this scenario, you can get query in your search function and create a list split with a comma and then apply a foreach loop on this list, then in this loop you can check contains to this solr index field. – Gaurav Agarwal Jul 21 at 7:15
  • Gaurav, I am looking for a solr query to do this all and give the final records . – Meenu Jul 21 at 7:28
  • yes Meenu, I am telling the same..suppose your method public abc xyx(string query){ // create a list by slpit comma //create a solr query here foreach(var a in list){ // add your logic here against solr query query = query.Where(i=>i.solrField.contains(a)); } } – Gaurav Agarwal Jul 21 at 7:41
  • or you can create predicate as well – Gaurav Agarwal Jul 21 at 7:44
  • 1
    Meenu check this - sitecore.stackexchange.com/questions/18362/… – Gaurav Agarwal Jul 21 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.