Package com.flaptor.hounder.searcher.group

Examples of com.flaptor.hounder.searcher.group.NoGroup


        int[] lenA={22}; // <= "<B>more</B> <B>more</B> comes first.".length()
        String[] fieldA={"text"};
        snippetSearcher= new SnippetSearcher(new CompositeSearcher(), fieldA, lenA, FRAG_SEP, PHRASE_BOUND, false, "<B>", "</B>");

        GroupedSearchResults results;       
        results = snippetSearcher.search(new LazyParsedQuery("more"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        org.apache.lucene.document.Document doc= results.getGroup(0).last().get(0);
        String content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
        assertEquals("The returned snippet is not as expected", "<B>more</B> <B>more</B> comes first.", content);
       
        // We should write the hilighted phrase, and then the surrounding ones
        int[] lenB={34}; // >= "have <B>has</B> twice <B>has</B>".length()+1       
        snippetSearcher= new SnippetSearcher(new CompositeSearcher(), fieldA, lenB, FRAG_SEP, PHRASE_BOUND, false, "<B>", "</B>");               
        results = snippetSearcher.search(new LazyParsedQuery("has"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        doc= results.getGroup(0).last().get(0);
        content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
        assertEquals("The returned snippet is not as expected", "more more comes first. " + "have <B>has</B> twice <B>has</B>", content);           
View Full Code Here


    }
       
    @TestInfo(testType = TestInfo.TestType.INTEGRATION)
    public void testFragmentSeparation() throws SearcherException {
        GroupedSearchResults results;       
        results = snippetSearcher.search(new LazyParsedQuery("separation"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        org.apache.lucene.document.Document doc= results.getGroup(0).last().get(0);
        String content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
        assertEquals("The returned snippet is not as expected", "test segments and their <B>separation</B>.", content);           
       
        results = snippetSearcher.search(new LazyParsedQuery("test"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        doc= results.getGroup(0).last().get(0);
        content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
        assertEquals("The returned snippet is not as expected", "This <B>test</B> will check!", content);           

        results = snippetSearcher.search(new LazyParsedQuery("different"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        doc= results.getGroup(0).last().get(0);
        content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
        assertEquals("The returned snippet is not as expected", "using <B>different</B> chars to separe the frags-", content);
       
        results = snippetSearcher.search(new LazyParsedQuery("chars"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        doc= results.getGroup(0).last().get(0);
        content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();       
        assertEquals("The returned snippet is not as expected", "<B>chars</B> and <B>chars</B> and <B>chars</B>", content);       
View Full Code Here

    }

    @TestInfo(testType = TestInfo.TestType.INTEGRATION)
    public void testSimplePhrase() throws SearcherException {       
        GroupedSearchResults results;
        results = snippetSearcher.search(new LazyParsedQuery("phrase"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, results.groups());
        assertEquals("We get a bad number of results within the group", 1, results.getGroup(0).last().size());
        org.apache.lucene.document.Document doc= results.getGroup(0).last().get(0);
        String content= StringUtil.nullToEmpty(doc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
        assertEquals("The returned snippet is not as expected", "This is a simple <B>phrase</B>", content);           
View Full Code Here

        body.addText(buf);
        doc.getRootElement().addElement("documentId").addText("mercury");
        indexer.index(doc);
        Execute.sleep(5000);

        GroupedSearchResults gsr = snippetSearcher.search(new LazyParsedQuery("diabetic ice cream"), 0, 10, new NoGroup(), 1, null, null);
        assertEquals("We get a bad number of groups", 1, gsr.groups());
        assertEquals("We get a bad number of results within the group", 1, gsr.getGroup(0).last().size());
       
        org.apache.lucene.document.Document luceneDoc = gsr.getGroup(0).last().get(0);
        String content= StringUtil.nullToEmpty(luceneDoc.get(SnippetSearcher.SNIPPET_FIELDNAME_PREFIX + "text")).trim();
View Full Code Here

            }
        }

        // Group (uni-valued)
        String groupParam = getParameter(params,"group");
        AGroup group = new NoGroup();
        if (groupParam != null) {
            if (groupParam.equals("site")) {
                group = new StoredFieldGroup("site");
            } else if (groupParam.equals("signature")) {
                group = new TextSignatureGroup("text");
View Full Code Here

TOP

Related Classes of com.flaptor.hounder.searcher.group.NoGroup

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.