Package org.apache.lucene.queryparser.classic

Examples of org.apache.lucene.queryparser.classic.MultiFieldQueryParser


        Highlighter highlighter = null;

        try
        {
            String[] queryfields = { LUCENE_PAGE_CONTENTS, LUCENE_PAGE_NAME, LUCENE_AUTHOR, LUCENE_ATTACHMENTS };
            QueryParser qp = new MultiFieldQueryParser( Version.LUCENE_46, queryfields, getLuceneAnalyzer() );

            //QueryParser qp = new QueryParser( LUCENE_PAGE_CONTENTS, getLuceneAnalyzer() );
            Query luceneQuery = qp.parse( query );

            if( (flags & FLAG_CONTEXTS) != 0 )
            {
                highlighter = new Highlighter(new SimpleHTMLFormatter("<span class=\"searchmatch\">", "</span>"),
                                              new SimpleHTMLEncoder(),
View Full Code Here


         Version version,
         String[] fieldNames,
         Analyzer analyzer
         )
    {
        return new MultiFieldQueryParser( version, fieldNames, analyzer );
    }
View Full Code Here

     * StandardAnalyzer instead of the XMLAnalyzer that was used to create
     * the index.
     */
    public static QueryParser createXMLQueryParser(
            Version version, String[] fields, Analyzer analyzer) {
        return new MultiFieldQueryParser(
                version, fields, new StandardAnalyzer(version));
    }
View Full Code Here

        public  QueryParser getQueryParser()
        {
            Version version = LuceneUtils.currentVersion();
           
            return new MultiFieldQueryParser
                (
                 version,
                 getFieldNames(),
                 new StandardAnalyzer( version )
                 );
View Full Code Here

      Session s = null;
      Transaction tx = null;
      try {
        s = sf.openSession();
        tx = s.beginTransaction();
        QueryParser parser = new MultiFieldQueryParser(
            TestConstants.getTargetLuceneVersion(),
            new String[] { "name", "physicalDescription", "suspectCharge" },
            TestConstants.standardAnalyzer
        );
        FullTextQuery query = getQuery( "John Doe", parser, s );
View Full Code Here

    @Override
    public void run() {
      Session s = sf.openSession();
      Transaction tx = s.beginTransaction();
      QueryParser parser = new MultiFieldQueryParser(
          TestConstants.getTargetLuceneVersion(),
          new String[] { "name", "physicalDescription", "suspectCharge" },
          TestConstants.standardAnalyzer
      );
      FullTextQuery query = getQuery( "John Doe", parser, s );
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( TestConstants.getTargetLuceneVersion(), new String[] {"title", "description"},
        TestConstants.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

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

    MultiFieldQueryParser parser = new MultiFieldQueryParser( TestConstants.getTargetLuceneVersion(),
        new String[] { "kurztext" }, TestConstants.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( TestConstants.getTargetLuceneVersion(),
        new String[] { "kurztext" }, TestConstants.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( TestConstants.getTargetLuceneVersion(),
        new String[] { "kurztext" }, TestConstants.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

TOP

Related Classes of org.apache.lucene.queryparser.classic.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.