Package com.flaptor.indextank.search

Examples of com.flaptor.indextank.search.SearchResults


        Iterable<SearchResult> results = Iterables.transform(ids, transformFunction);       

        // fix'em in a list
        results = Lists.newArrayList(results);

        return new SearchResults(results, matches.getTotalMatches(), matches.getFacetingResults());
    }
View Full Code Here


    public void testSwitch() throws IOException, ParseException, InterruptedException {
      indexTwelveDocs(this.indexEngine.getIndexer());

        DocumentSearcher searcher = this.indexEngine.getSearcher();

        SearchResults srs = searcher.search(new Query(new TermQuery("text","term1"),null,null),0,10, 0);
    assertEquals("Number of historic results doesn't match", 1, srs.getMatches());
       
        srs = searcher.search(new Query(new TermQuery("text","term11"),null,null),0,10, 0);
    assertEquals("Number of real time results doesn't match", 1, srs.getMatches());

        Query query = new Query(this.indexEngine.getParser().parseQuery("term1 OR term2 OR term3 OR term4 OR term5"),null,null);
        srs = searcher.search(query,0,10, 0);
    assertEquals("Number of real time results doesn't match", 5, srs.getMatches());
  }
View Full Code Here

    public void testSwitchedDuplicates() throws IOException, ParseException, InterruptedException {
      indexLengthDifferentDocs(this.indexEngine.getIndexer(), 33, 1);
      indexLengthDifferentDocs(this.indexEngine.getIndexer(), 33, 2);
     
      Query query = new Query(this.indexEngine.getParser().parseQuery("foo"),null,null);
      SearchResults srs = this.indexEngine.getSearcher().search(query,0,100, 0);
     
     
      assertEquals("Number of results doesn't match", 33, srs.getMatches());
      Multiset<String> ids = HashMultiset.create();
      for (SearchResult r : srs.getResults()) {
      ids.add(r.getDocId());
    }
      assertEquals("Number of actual results doesn't match", 33, ids.size());
      assertEquals("Number of different results doesn't match", 33, ids.elementSet().size());
    }
View Full Code Here

      assertEquals("Number of actual results doesn't match", 33, ids.size());
      assertEquals("Number of different results doesn't match", 33, ids.elementSet().size());
    }
   
    private void checkResults(DocumentSearcher searcher, int start, int len, int[] expectedIds) throws InterruptedException {
        SearchResults srs = searcher.search(new Query(new TermQuery("text","fixed"),"fixed",null),start,len, 0);
        Set<Integer> expIds = Sets.newHashSet();
        for (int i : expectedIds) {
            expIds.add(i);
        }
        int n = 0;
        Set<Integer> actIds = Sets.newHashSet();
        for (SearchResult r : srs.getResults()) {
            String docid = r.getDocId();
            int i = Integer.parseInt(docid.substring(docid.indexOf('_')+1));
            actIds.add(i);
            n++;
        }
View Full Code Here

    @TestInfo(testType=SYSTEM)
    public void testFacetedSearch() throws InterruptedException {
      indexForwardFacetedToDocuments(this.indexEngine.getIndexer());
        DocumentSearcher searcher = this.indexEngine.getSearcher();
       
        SearchResults searchResults = searcher.search(new Query(new TermQuery("text","a"),"a",null), 0, 10, 0);
       
        Map<String, Multiset<String>> facets = searchResults.getFacets();
       
        //System.out.println("Matches: " + searchResults.getMatches());
        //System.out.println(facets);
       
        assertEquals(2, facets.keySet().size());
       
        Multiset<String> precioFacet = facets.get("PRECIO");
    
        assertEquals(2, precioFacet.elementSet().size());
        assertEquals(2, precioFacet.count("ALTO"));
        assertEquals(3, precioFacet.count("BAJO"));
       
        Multiset<String> tipoFacet = facets.get("TIPO");
       
        assertEquals(2, tipoFacet.elementSet().size());
        assertEquals(3, tipoFacet.count("NAH"));
        assertEquals(2, tipoFacet.count("SI"));
       
       
        searchResults = searcher.search(new Query(new TermQuery("text","b"),"b",null), 0, 10, 0);
       
        facets = searchResults.getFacets();
       
        //System.out.println("Matches: " + searchResults.getMatches());
        //System.out.println(facets);
       
        assertEquals(2, facets.keySet().size());
View Full Code Here

    @TestInfo(testType=SYSTEM)
    public void testBackwardsFacetedSearch() throws InterruptedException {
      indexBackwardsFacetedToDocuments(this.indexEngine.getIndexer());
        DocumentSearcher searcher = this.indexEngine.getSearcher();
       
        SearchResults searchResults = searcher.search(new Query(new TermQuery("text","a"),"a",null), 0, 10, 0);
       
        Map<String, Multiset<String>> facets = searchResults.getFacets();
       
        //System.out.println("Matches: " + searchResults.getMatches());
        //System.out.println(facets);
       
        assertEquals(2, facets.keySet().size());
       
        Multiset<String> precioFacet = facets.get("PRECIO");
    
        assertEquals(2, precioFacet.elementSet().size());
        assertEquals(2, precioFacet.count("ALTO"));
        assertEquals(3, precioFacet.count("BAJO"));
       
        Multiset<String> tipoFacet = facets.get("TIPO");
       
        assertEquals(2, tipoFacet.elementSet().size());
        assertEquals(3, tipoFacet.count("NAH"));
        assertEquals(2, tipoFacet.count("SI"));
       
       
        searchResults = searcher.search(new Query(new TermQuery("text","b"),"b",null), 0, 10, 0);
       
        facets = searchResults.getFacets();
       
        //System.out.println("Matches: " + searchResults.getMatches());
        //System.out.println(facets);
       
        assertEquals(2, facets.keySet().size());
View Full Code Here

       
        Multimap<String, String> categoriesFilter = HashMultimap.create();
       
        categoriesFilter.put("PRECIO", "BAJO");
       
    SearchResults searchResults = searcher.search(new Query(indexEngine.getParser().parseQuery("a OR b"),"a OR b", null, categoriesFilter, VariablesRangeFilter.NO_FILTER), 0, 10, 0);
   
    int matches = searchResults.getMatches();
    Map<String, Multiset<String>> facets = searchResults.getFacets();
    //System.out.println(matches);
    //System.out.println(searchResults.getResults());
    //System.out.println(searchResults.getFacets());
   
    assertEquals(4, matches);
    checkSearchResults(searchResults.getResults(), new String[] {"D6", "D5", "D2", "D1"});
   
    categoriesFilter = HashMultimap.create();
   
    categoriesFilter.put("TIPO", "NAH");
    categoriesFilter.put("TIPO", "TERCERO");
   
    searchResults = searcher.search(new Query(indexEngine.getParser().parseQuery("a OR b"),"a OR b", null, categoriesFilter, VariablesRangeFilter.NO_FILTER), 0, 10, 0);
   
    matches = searchResults.getMatches();
    //System.out.println(matches);
    //System.out.println(searchResults.getResults());
    //System.out.println(searchResults.getFacets());

    assertEquals(5, matches);
    checkSearchResults(searchResults.getResults(), new String[] {"D8", "D7", "D5", "D3", "D1"});

    categoriesFilter = HashMultimap.create();
   
    categoriesFilter.put("TIPO", "NAH");
    categoriesFilter.put("TIPO", "TERCERO");
    categoriesFilter.put("PRECIO", "BAJO");
   
    searchResults = searcher.search(new Query(indexEngine.getParser().parseQuery("a OR b"),"a OR b", null, categoriesFilter, VariablesRangeFilter.NO_FILTER), 0, 10, 0);
   
    matches = searchResults.getMatches();
    //System.out.println(matches);
    //System.out.println(searchResults.getResults());
    //System.out.println(searchResults.getFacets());
   
    assertEquals(2, matches);
    checkSearchResults(searchResults.getResults(), new String[] {"D5", "D1"});

    }
View Full Code Here

        res2.addResult(0.7f,"12");
        res2.addResult(0.7f,"13");
        res2.addResult(0.7f,"14");
        res2.addResult(0.7f,"15");

        SearchResults res = blender.search(dummyQuery, 0, 5, 0);
    assertEquals("Number of total results doesn't match", res.getMatches(), 10);

        List<SearchResult> lsr1 = Lists.newArrayList(res.getResults());
        assertEquals("Number of results doesn't match",lsr1.size(),5);

        res = blender.search(dummyQuery,5,10, 0);
    assertEquals("Number of total results doesn't match", res.getMatches(), 10);
       
        List<SearchResult> lsr2 = Lists.newArrayList(res.getResults());
        assertEquals("Number of results doesn't match",lsr1.size(),5);

        Set<String> docids = Sets.newHashSet();
        // concatenate all the doc ids, and put them on a set
        docids.addAll(Lists.newArrayList(Iterables.transform(Iterables.concat(lsr1,lsr2),new Function<SearchResult,String>(){
View Full Code Here

        this.indexEngine.getIndexer().add(String.valueOf(id), doc, (int)t, ImmutableMap.<Integer, Double>of());
    }

    private void checkResults(String name, DocumentSearcher searcher, Query query, int scoringFunction, String[] expectedIds) throws InterruptedException {
        //System.out.println("TESTING query: ["+query.toString()+"]");
        SearchResults srs = searcher.search(query, 0, 100, scoringFunction);
      int i = 0;
        boolean equals = true;
        String actualStr = "";
      for (SearchResult r : srs.getResults()) {
            equals = equals && (i < expectedIds.length) && (r.getDocId().equals(expectedIds[i]));
            actualStr += r.getDocId()+" ";
        i++;
      }
        assertTrue(name+": Results out of order: expected "+Arrays.toString(expectedIds)+", actual ["+actualStr.trim().replaceAll(" ",", ")+"]", equals);
View Full Code Here

        for (int i = 0; i < 100; i++) {
            index(i, t+i);
        }
       
        Query q = new Query(this.indexEngine.getParser().parseQuery("text"),null,null);
        SearchResults rs = this.indexEngine.getSearcher().search(q, 0, 100, 0);
       
        Iterable<SearchResult> results = rs.getResults();
       
        int n = 99;
        for (SearchResult r : results) {
            assertEquals("Age: Results out of order", String.valueOf(n), r.getDocId());
            n--;
View Full Code Here

TOP

Related Classes of com.flaptor.indextank.search.SearchResults

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.