Package org.apache.lucene.search

Examples of org.apache.lucene.search.WildcardQuery


    directory.close();
    super.tearDown();
  }
 
  public void testWildcard() throws Exception {
    WildcardQuery wq = new WildcardQuery(new Term("field", "bro?n"));
    SpanQuery swq = new SpanMultiTermQueryWrapper<WildcardQuery>(wq);
    // will only match quick brown fox
    SpanFirstQuery sfq = new SpanFirstQuery(swq, 2);
    assertEquals(1, searcher.search(sfq, 10).totalHits);
  }
View Full Code Here


    SpanFirstQuery sfq = new SpanFirstQuery(swq, 2);
    assertEquals(1, searcher.search(sfq, 10).totalHits);
  }
 
  public void testPrefix() throws Exception {
    WildcardQuery wq = new WildcardQuery(new Term("field", "extrem*"));
    SpanQuery swq = new SpanMultiTermQueryWrapper<WildcardQuery>(wq);
    // will only match "jumps over extremely very lazy broxn dog"
    SpanFirstQuery sfq = new SpanFirstQuery(swq, 3);
    assertEquals(1, searcher.search(sfq, 10).totalHits);
  }
View Full Code Here

    assertNull( fq.searchPhrase( F, phraseCandidate ) );
  }
 
  public void testHighlightQuery() throws Exception {
    makeIndexStrMV();
    defgMultiTermQueryTest(new WildcardQuery(new Term(F, "d*g")));
  }
View Full Code Here

  @Ignore("flexible queryparser shouldn't escape wildcard terms")
  public void testEscapedWildcard() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));

    WildcardQuery q = new WildcardQuery(new Term("field", "foo\\?ba?r"));
    assertEquals(q, qp.parse("foo\\?ba?r", "field"));
  }
View Full Code Here

  }

 
  public void testWildcard() throws Exception {
    makeIndexLongMV();
    FieldQuery fq = new FieldQuery( new WildcardQuery (new Term(F, "th*e")), reader, true, true );
    FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
    assertEquals (4, stack.termList.size());
    assertEquals ("the(15,18,2)", stack.pop().toString());
    assertEquals ("these(133,138,20)", stack.pop().toString());
    assertEquals ("the(153,156,23)", stack.pop().toString());
View Full Code Here

         final ValueFactoryImpl valueFactory = new ValueFactoryImpl(new LocationFactory(nsReg));
         BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
         BooleanQuery query = new BooleanQuery();

         final String prefix = nsReg.getNamespacePrefixByURI(uri);
         query.add(new WildcardQuery(new Term(FieldNames.LABEL, prefix + ":*")), Occur.SHOULD);
         // name of the property
         query.add(new WildcardQuery(new Term(FieldNames.PROPERTIES_SET, prefix + ":*")), Occur.SHOULD);

         result = getNodes(query);

         // value of the property

         try
         {
            final Set<String> props = getFieldNames();

            query = new BooleanQuery();
            for (final String fieldName : props)
            {
               if (!FieldNames.PROPERTIES_SET.equals(fieldName))
               {
                  query.add(new WildcardQuery(new Term(fieldName, "*" + prefix + ":*")), Occur.SHOULD);
               }
            }
         }
         catch (final IndexException e)
         {
View Full Code Here

    switch ( termContext.getApproximation() ) {
      case EXACT:
        query = new TermQuery( new Term( fieldName, term ) );
        break;
      case WILDCARD:
        query = new WildcardQuery( new Term( fieldName, term ) );
        break;
      case FUZZY:
        query = new FuzzyQuery(
            new Term( fieldName, term ),
            termContext.getThreshold(),
View Full Code Here

    switch ( termContext.getApproximation() ) {
      case EXACT:
        query = new TermQuery( new Term( fieldName, term ) );
        break;
      case WILDCARD:
        query = new WildcardQuery( new Term( fieldName, term ) );
        break;
      case FUZZY:
        query = new FuzzyQuery(
            new Term( fieldName, term ),
            termContext.getThreshold(),
View Full Code Here

         final ValueFactoryImpl valueFactory = new ValueFactoryImpl(new LocationFactory(nsReg));
         BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
         BooleanQuery query = new BooleanQuery();

         final String prefix = nsReg.getNamespacePrefixByURI(uri);
         query.add(new WildcardQuery(new Term(FieldNames.LABEL, prefix + ":*")), Occur.SHOULD);
         // name of the property
         query.add(new WildcardQuery(new Term(FieldNames.PROPERTIES_SET, prefix + ":*")), Occur.SHOULD);

         result = getNodes(query);

         // value of the property

         try
         {
            final Set<String> props = getFieldNames();

            query = new BooleanQuery();
            for (final String fieldName : props)
            {
               if (!FieldNames.PROPERTIES_SET.equals(fieldName))
               {
                  query.add(new WildcardQuery(new Term(fieldName, "*" + prefix + ":*")), Occur.SHOULD);
               }
            }
         }
         catch (final IndexException e)
         {
View Full Code Here

    switch ( termContext.getApproximation() ) {
      case EXACT:
        query = new TermQuery( new Term( fieldName, term ) );
        break;
      case WILDCARD:
        query = new WildcardQuery( new Term( fieldName, term ) );
        break;
      case FUZZY:
        query = new FuzzyQuery(
            new Term( fieldName, term ),
            termContext.getThreshold(),
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.WildcardQuery

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.