Examples of InputArrayIterator


Examples of org.apache.lucene.search.suggest.InputArrayIterator

  public void testNonExactFirst() throws Exception {

    WFSTCompletionLookup suggester = new WFSTCompletionLookup(false);

    suggester.build(new InputArrayIterator(new Input[] {
          new Input("x y", 20),
          new Input("x", 2),
        }));

    for(int topN=1;topN<4;topN++) {
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

      slowCompletor.put(s, (long)weight);
      keys[i] = new Input(s, weight);
    }

    WFSTCompletionLookup suggester = new WFSTCompletionLookup(false);
    suggester.build(new InputArrayIterator(keys));

    Random random = new Random(random().nextLong());
    for (String prefix : allPrefixes) {
      final int topN = _TestUtil.nextInt(random, 1, 10);
      List<LookupResult> r = suggester.lookup(_TestUtil.stringToCharSequence(prefix, random), false, topN);
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    BytesRef key2 = new BytesRef(3);
    key1.length = 3;

    WFSTCompletionLookup suggester = new WFSTCompletionLookup(false);

    suggester.build(new InputArrayIterator(new Input[] {
          new Input(key1, 50),
          new Input(key2, 50),
        }));
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

  }

  public void testEmpty() throws Exception {
    WFSTCompletionLookup suggester = new WFSTCompletionLookup(false);

    suggester.build(new InputArrayIterator(new Input[0]));
    List<LookupResult> result = suggester.lookup("a", false, 20);
    assertTrue(result.isEmpty());
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

        new Input("bar", 5),
        new Input("barbara", 1)
    );

    AnalyzingSuggester suggester = new AnalyzingSuggester(new MockAnalyzer(random(), MockTokenizer.KEYWORD, false));
    suggester.build(new InputArrayIterator(keys));
   
    // top N of 2, but only foo is available
    List<LookupResult> results = suggester.lookup(_TestUtil.stringToCharSequence("f", random()), false, 2);
    assertEquals(1, results.size());
    assertEquals("foo", results.get(0).key.toString());
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

      new Input("bar", 9, new BytesRef("should be deduplicated")),
      new Input("bar", 8, new BytesRef("should also be deduplicated")),
      new Input("barbara", 6, new BytesRef("for all the fish")));
   
    AnalyzingSuggester suggester = new AnalyzingSuggester(new MockAnalyzer(random(), MockTokenizer.KEYWORD, false));
    suggester.build(new InputArrayIterator(keys));
    for (int i = 0; i < 2; i++) {
      // top N of 2, but only foo is available
      List<LookupResult> results = suggester.lookup(_TestUtil.stringToCharSequence("f", random()), false, 2);
      assertEquals(1, results.size());
      assertEquals("foo", results.get(0).key.toString());
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    if (doPayloads) {
      List<Input> keysAndPayloads = new ArrayList<Input>();
      for (Input termFreq : keys) {
        keysAndPayloads.add(new Input(termFreq.term, termFreq.v, new BytesRef(Long.toString(termFreq.v))));
      }
      analyzingSuggester.build(new InputArrayIterator(keysAndPayloads));
    } else {
      analyzingSuggester.build(new InputArrayIterator(keys))
    }
   
    for (Input termFreq : keys) {
      List<LookupResult> lookup = analyzingSuggester.lookup(termFreq.term.utf8ToString(), false, keys.size());
      for (LookupResult lookupResult : lookup) {
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

   
    Analyzer standard = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET);
    AnalyzingSuggester suggester = new AnalyzingSuggester(standard, standard,
        AnalyzingSuggester.EXACT_FIRST | AnalyzingSuggester.PRESERVE_SEP, 256, -1, false);

    suggester.build(new InputArrayIterator(keys));
   
    List<LookupResult> results = suggester.lookup(_TestUtil.stringToCharSequence("the ghost of chris", random()), false, 1);
    assertEquals(1, results.size());
    assertEquals("the ghost of christmas past", results.get(0).key.toString());
    assertEquals(50, results.get(0).value, 0.01F);
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

  }

  public void testEmpty() throws Exception {
    Analyzer standard = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET);
    AnalyzingSuggester suggester = new AnalyzingSuggester(standard);
    suggester.build(new InputArrayIterator(new Input[0]));

    List<LookupResult> result = suggester.lookup("a", false, 20);
    assertTrue(result.isEmpty());
  }
View Full Code Here

Examples of org.apache.lucene.search.suggest.InputArrayIterator

    int options = 0;

    Analyzer a = new MockAnalyzer(random());
    AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, options, 256, -1, true);
    suggester.build(new InputArrayIterator(keys));
    // TODO: would be nice if "ab " would allow the test to
    // pass, and more generally if the analyzer can know
    // that the user's current query has ended at a word,
    // but, analyzers don't produce SEP tokens!
    List<LookupResult> r = suggester.lookup(_TestUtil.stringToCharSequence("ab c", random()), false, 2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.