Package com.flaptor.indextank.index

Examples of com.flaptor.indextank.index.Document


        assertEquals("Wrong document count", 1, index.getLuceneIndexWriter().numDocs());
  }
   
    @TestInfo(testType=UNIT)
  public void testHandleMultipleAdds() throws IOException, InterruptedException {
        Document doc = new Document();
        doc.setField("fieldA","A");
        doc.setField("fieldB","B");

        lsiIndexer.add("A",doc);
        lsiIndexer.add("B",doc);
        lsiIndexer.add("C",doc);
        lsiIndexer.makeDirectoryCheckpoint();
View Full Code Here


        assertEquals("Wrong document count", 3, index.getLuceneIndexWriter().numDocs());
  }
   
    @TestInfo(testType=UNIT)
  public void testHandleDeleteMissingDocument() throws IOException, InterruptedException {
        Document doc = new Document();
        doc.setField("fieldA","A");
        doc.setField("fieldB","B");

        lsiIndexer.add("A",doc);
        lsiIndexer.add("B",doc);
        lsiIndexer.del("C"); // does not exist
        lsiIndexer.makeDirectoryCheckpoint();
View Full Code Here

  public static Iterable<String> toDocIds(TopMatches result) {
    return Iterables.transform(result, GET_ID_FUNCTION);
  }

  public static Document createDocument(String text) {
    return new Document(ImmutableMap.of("text", text));
  }
View Full Code Here

    private void index(int id, long t) {
        String text = "text word" + id;
        for (int i = 0; i < new Random().nextInt(25); i++) {
            text += " text";
        }
        Document doc = new Document(ImmutableMap.of("text", text, "timestamp", String.valueOf(t)));
        this.indexEngine.getIndexer().add(String.valueOf(id), doc, (int)t, ImmutableMap.<Integer, Double>of());
    }
View Full Code Here

    public void testRelevanceOrder() throws Exception {
        DocumentSearcher searcher = this.indexEngine.getSearcher();
        BoostingIndexer indexer = this.indexEngine.getIndexer();
        indexer.addScoreFunction(1, "relevance");

        Document doc = new Document(ImmutableMap.of("relevance_test", "Twinkle twinkle you better work"));
        indexer.add("1", doc, 0, ImmutableMap.<Integer, Double>of());
        doc = new Document(ImmutableMap.of("relevance_test", "Twinkle you better work or else I'll hack you"));     
        indexer.add("2", doc, 1, ImmutableMap.<Integer, Double>of());
        doc = new Document(ImmutableMap.of("relevance_test", "Twinkle you better work"));     
        indexer.add("3", doc, 2, ImmutableMap.<Integer, Double>of());
       
        Query q = new Query(this.indexEngine.getParser().parseQuery("relevance_test:twinkle"),null,null);

        checkResults("Relevance", searcher, q, 1, new String[] {"1","3","2"});
View Full Code Here

    @TestInfo(testType=SYSTEM)
    public void testCaretQueries() throws InterruptedException, ParseException, Exception {
        DocumentSearcher searcher = this.indexEngine.getSearcher();
        BoostingIndexer indexer = this.indexEngine.getIndexer();
        indexer.addScoreFunction(1, "relevance");
        Document doc;
        Query query;

        doc = new Document(ImmutableMap.of("text", "aaa"));
        indexer.add("1", doc, 0, ImmutableMap.<Integer, Double>of());

        doc = new Document(ImmutableMap.of("text", "aaa bbb"));
        indexer.add("2", doc, 0, ImmutableMap.<Integer, Double>of());

        doc = new Document(ImmutableMap.of("text", "aaa aaa bbb"));
        indexer.add("3", doc, 0, ImmutableMap.<Integer, Double>of());

        doc = new Document(ImmutableMap.of("text", "aaa bbb ccc eee"));
        indexer.add("4", doc, 0, ImmutableMap.<Integer, Double>of());

        doc = new Document(ImmutableMap.of("text", "ccc ddd"));
        indexer.add("5", doc, 0, ImmutableMap.<Integer, Double>of());

        query = new Query(indexEngine.getParser().parseQuery("aaa"),null,null);
        checkResults("Caret", searcher, query, 1, new String[] {"1","3","2","4"});
View Full Code Here

        return result;
    }
   
    public void putDocument(String id, JSONObject fields, JSONObject variables, JSONObject categories) {
        BoostingIndexer indexer = engine.getIndexer();
        indexer.add(id, new Document(prepareProperties(fields)), Timestamp.inSeconds(), prepareBoosts(variables));
        indexer.updateCategories(id, prepareProperties(categories));
    }
View Full Code Here

                        timestamp = Integer.valueOf(record.get_fields().get("timestamp"));
                    } catch (NumberFormatException e) {
                        logger.warn("Document " + record.get_docid() + " had an invalid timestamp '" + record.get_fields().get("timestamp") + "', skipping it.");
                        continue;
                    }
                    Document document = new Document(record.get_fields());
                    indexer.add(record.get_docid(), document, timestamp, record.get_variables());
                } else {
                    indexer.updateBoosts(record.get_docid(), record.get_variables());
                }
               
View Full Code Here

TOP

Related Classes of com.flaptor.indextank.index.Document

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.