Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-19682

Solr ParseException from SimpleEventQuery when comparing with equality to empty string

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 14.4.2, 13.10.7, 14.5
    • 13.10.5, 14.3
    • Event Stream
    • None
    • Unit
    • Unknown
    • N/A
    • N/A
    • Pull Request accepted

    Description

      When using an equals comparison with an empty string in SimpleEventQuery, the generated Solr query is invalid as Solr doesn't like it when the value is empty, see this Stack Overflow question for details. Groovy snippet to reproduce:

      {{groovy}}
      def eventStore = services.component.getInstance(org.xwiki.eventstream.EventStore)
      def eventQuery = new org.xwiki.eventstream.query.SimpleEventQuery(0, 30)
        eventQuery.eq(org.xwiki.eventstream.Event.FIELD_DOCUMENT, '')
        try (org.xwiki.eventstream.EventSearchResult searchResult = eventStore.search(eventQuery)) {
          println("Total result: " + searchResult.getTotalHits())
        }
      {{/groovy}}
      

      Root cause of the exception: Caused by: org.apache.solr.parser.ParseException: Encountered "<EOF>" at line 1, column 15..

      As a workaround, eventQuery.not().less(org.xwiki.eventstream.Event.FIELD_DOCUMENT, null) can be used to search for events without document.

      Attachments

        Activity

          People

            MichaelHamann Michael Hamann
            MichaelHamann Michael Hamann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: