Class LuceneQueryBuilder


  • public class LuceneQueryBuilder
    extends java.lang.Object
    Utility class for building lucene queries

    Example:
    Fields to search for: 'name', 'description'
    Input query: a b AND c AND d f

    will be transformed to this lucene expression:
    name:a description:a name:f description:f ((name:b description:b) AND (name:c description:c) AND (name:d description:d))

    Since:
    5.0 TODO: For versions greater than 5.0 this class can be moved from commons to the server
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DATE_ACQUISITION  
      static java.lang.String DATE_IMPORT  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildLuceneQuery​(java.util.List<java.lang.String> fields, java.lang.String input)
      Builds a query with the provided input terms over the given fields
      static java.lang.String buildLuceneQuery​(java.util.List<java.lang.String> fields, java.util.Date from, java.util.Date to, java.lang.String dateType, java.lang.String input)
      Builds a query with the provided input terms over the given fields
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LuceneQueryBuilder

        public LuceneQueryBuilder()
    • Method Detail

      • buildLuceneQuery

        public static java.lang.String buildLuceneQuery​(java.util.List<java.lang.String> fields,
                                                        java.util.Date from,
                                                        java.util.Date to,
                                                        java.lang.String dateType,
                                                        java.lang.String input)
                                                 throws InvalidQueryException
        Builds a query with the provided input terms over the given fields
        Parameters:
        fields -
        input -
        Returns:
        the query
        Throws:
        InvalidQueryException
      • buildLuceneQuery

        public static java.lang.String buildLuceneQuery​(java.util.List<java.lang.String> fields,
                                                        java.lang.String input)
                                                 throws InvalidQueryException
        Builds a query with the provided input terms over the given fields
        Parameters:
        fields -
        input -
        Returns:
        the query
        Throws:
        InvalidQueryException