Package org.apache.lucene.queryParser

Examples of org.apache.lucene.queryParser.MultiFieldQueryParser


        boostPerField.put(bookFields[2], (float) 4);
        boostPerField.put(bookFields[3], (float) .5);

        FullTextEntityManager ftEm = org.hibernate.search.jpa.Search.getFullTextEntityManager((EntityManager) em);

        QueryParser parser = new MultiFieldQueryParser(bookFields, ftEm.getSearchFactory().getAnalyzer("customanalyzer"),
                boostPerField);

        org.apache.lucene.search.Query luceneQuery;
        luceneQuery = parser.parse(searchQuery);

        final FullTextQuery query = ftEm.createFullTextQuery(luceneQuery, Book.class);

        return query;
    }
View Full Code Here


    // Search
    Session session = openSession();
    Transaction tx = session.beginTransaction();
    FullTextSession fullTextSession = Search.getFullTextSession( session );

    MultiFieldQueryParser parser = new MultiFieldQueryParser(
        new String[] { "kurztext" }, new StandardAnalyzer()
    );
    Query query = parser.parse( "combi OR sport" );

    Criteria criteria = session.createCriteria( AbstractCar.class );
    criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, AbstractCar.class )
View Full Code Here

    // Search
    Session session = openSession();
    Transaction tx = session.beginTransaction();
    FullTextSession fullTextSession = Search.getFullTextSession( session );

    MultiFieldQueryParser parser = new MultiFieldQueryParser(
        new String[] { "kurztext" }, new StandardAnalyzer()
    );
    Query query = parser.parse( "combi OR sport" );

    Criteria criteria = session.createCriteria( AbstractCar.class );
    criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );

    org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query )
View Full Code Here

    // Search
    Session session = openSession();
    Transaction tx = session.beginTransaction();
    FullTextSession fullTextSession = Search.getFullTextSession( session );

    MultiFieldQueryParser parser = new MultiFieldQueryParser(
        new String[] { "kurztext" }, new StandardAnalyzer()
    );
    Query query = parser.parse( "combi OR sport" );

    Criteria criteria = session.createCriteria( AbstractCar.class );
    criteria.add( Restrictions.eq( "hasColor", Boolean.FALSE ) );

    try {
View Full Code Here

    tx = s.beginTransaction();
    Map<String, Float> boosts = new HashMap<String, Float>(2);
    boosts.put( "title", new Float(4) );
    boosts.put( "description", new Float(1) );
    MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[] {"title", "description"}, new StandardAnalyzer(), boosts);
    Query luceneQuery = parser.parse( "dark" );
    FullTextQuery ftQuery = s.createFullTextQuery( luceneQuery, Dvd.class )
        .setProjection( FullTextQuery.DOCUMENT_ID, FullTextQuery.EXPLANATION, FullTextQuery.THIS );
    @SuppressWarnings("unchecked") List<Object[]> results = ftQuery.list();
    assertEquals( 2, results.size() );
    for (Object[] result : results) {
View Full Code Here

    }

    public void run() {
      Session s = sf.openSession();
      Transaction tx = s.beginTransaction();
      QueryParser parser = new MultiFieldQueryParser(
          new String[] { "name", "physicalDescription", "suspectCharge" },
          new StandardAnalyzer()
      );
      FullTextQuery query = getQuery( "John Doe", parser, s );
      assertTrue( query.getResultSize() != 0 );
View Full Code Here

    }

    public void run() {
      Session s = sf.openSession();
      Transaction tx = s.beginTransaction();
      QueryParser parser = new MultiFieldQueryParser(
          new String[] { "name", "physicalDescription", "suspectCharge" },
          new StandardAnalyzer()
      );
      FullTextQuery query = getQuery( "John Doe", parser, s );
      assertTrue( query.getResultSize() != 0 );
View Full Code Here

            }

            //build a query based on the fields, searchString and cached analyzer
            //NOTE: This is an area for improvement since the MultiFieldQueryParser
            // has some weirdness.
            MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
            Query query = parser.parse(searchString);
            //run the search
            Hits hits = is.search(query);
            //reset this table model with the new results
            resetSearchResults(hits);
        } catch (Exception e){
View Full Code Here

            String[] fields = {FIELD_NAME};

            //build a query based on the fields, searchString and cached analyzer
            //NOTE: This is an area for improvement since the MultiFieldQueryParser
            // has some weirdness.
            MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, analyzer);
            Query query =parser.parse(searchString);
            //run the search
            Hits hits = is.search(query);
            //reset this list model with the new results
            resetSearchResults(hits);
        } catch (Exception e){
View Full Code Here

    int arraySize = indexedFields.size();
    String indexedArray[] = new String[arraySize];
    for (int ii = 0; ii < arraySize; ii++) {
      indexedArray[ii] = (String) indexedFields.get(ii);
    }
    MultiFieldQueryParser parser = new MultiFieldQueryParser(indexedArray, analyzer);
    query = parser.parse(queryString);
    System.out.println("Searching for: " + query.toString());
    return (query);

  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.queryParser.MultiFieldQueryParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.