Uploaded image for project: 'Spring Data for Apache Solr'
  1. Spring Data for Apache Solr
  2. DATASOLR-105

Chaining Criteria does not produce the expected parenthesization

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0 RC1, 1.0 GA
    • Fix Version/s: 1.2 M1 (Dijkstra)
    • Component/s: Core
    • Labels:
    • Sprint:
      44 - Codd GA

      Description

      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

      Criteria c = Criteria.where("text").startsWith("anssi")
      		.and(Criteria.where("text").startsWith("40764"))
      		.or(Criteria.where("id").is(40764));
      

      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).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cstrobl Christoph Strobl
              Reporter:
              atorma Anssi Törmä
              Last updater:
              Spring Issues
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: