Package sagan.search

Examples of sagan.search.SearchEntry


    @Test
    public void searchPagesProperly() throws ParseException {
        SearchEntryBuilder builder = SearchEntryBuilder.entry().rawContent("raw content")
                .summary("Html summary").publishAt("2013-01-01 10:00");

        SearchEntry entry1 = builder.path("item1").title("Item 1").build();
        searchService.saveToIndex(entry1);

        SearchEntry entry2 = builder.path("item2").title("Item 2").build();
        searchService.saveToIndex(entry2);

        Pageable page1 = new PageRequest(0, 1);
        Page<SearchResult> searchEntries1 =
                searchService.search("content", page1, Collections.<String> emptyList()).getPage();
        assertThat(searchEntries1.getContent().get(0).getId(), equalTo(entry1.getId()));

        Pageable page2 = new PageRequest(1, 1);
        Page<SearchResult> searchEntries2 =
                searchService.search("content", page2, Collections.<String> emptyList()).getPage();
        assertThat(searchEntries2.getContent().get(0).getId(), equalTo(entry2.getId()));
    }
View Full Code Here


    public void searchQueryReportsPageTotals() throws Exception {
        SearchEntryBuilder builder = SearchEntryBuilder.entry().rawContent("raw content")
                .summary("Html summary").publishAt("2013-01-01 10:00");

        for (int i = 0; i < 25; i++) {
            SearchEntry entry = builder.path("item" + i).title("Item " + i).build();
            searchService.saveToIndex(entry);
        }

        int page = 1;
        Pageable pageable = new PageRequest(page, 10);
View Full Code Here

        assertThatSearchReturnsEntry("export");
    }

    @Test
    public void boostsTitleMatchesOverContent() throws ParseException {
        SearchEntry entryContent = SearchEntryBuilder.entry()
                .path("http://example.com/content").title("a title")
                .rawContent("application is in the content").summary("Html summary")
                .publishAt("2013-01-01 10:00").build();

        searchService.saveToIndex(entryContent);

        SearchEntry entryTitle = SearchEntryBuilder.entry()
                .path("http://example.com/title").title("application is in the title")
                .rawContent("some content").summary("Html summary")
                .publishAt("2013-01-01 10:00").build();

        searchService.saveToIndex(entryTitle);

        List<SearchResult> results = searchService
                .search("application", pageable, Collections.<String> emptyList())
                .getPage().getContent();
        assertThat(results.get(0).getId(), is(entryTitle.getId()));
        assertThat(results.get(1).getId(), is(entryContent.getId()));
    }
View Full Code Here

        assertThat(results.get(1).getId(), is(entryContent.getId()));
    }

    @Test
    public void boostsCurrentVersionEntries() throws ParseException {
        SearchEntry notCurrent = SearchEntryBuilder.entry()
                .path("http://example.com/content").title("a title")
                .rawContent("application is in the content").summary("Html summary")
                .publishAt("2013-01-01 10:00").notCurrent().build();

        searchService.saveToIndex(notCurrent);

        SearchEntry current = SearchEntryBuilder.entry()
                .path("http://example.com/another_one").title("a title")
                .rawContent("application is in the content").summary("Html summary")
                .publishAt("2013-01-01 10:00").build();

        searchService.saveToIndex(current);

        List<SearchResult> results = searchService
                .search("application", pageable, Collections.<String> emptyList())
                .getPage().getContent();
        assertThat(results.get(0).getId(), is(current.getId()));
        assertThat(results.get(1).getId(), is(notCurrent.getId()));
    }
View Full Code Here

        assertThat(results.get(1).getId(), is(notCurrent.getId()));
    }

    @Test
    public void returnsApiDocSearchResult() throws ParseException {
        SearchEntry apiDoc = SearchEntryBuilder.entry()
                .path("http://example.com/content").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .notCurrent().type("apiDoc").build();

        searchService.saveToIndex(apiDoc);

        List<SearchResult> results = searchService
                .search("ApplicationContext", pageable,
                        Collections.<String> emptyList()).getPage().getContent();
        assertThat(results.get(0).getId(), is(apiDoc.getId()));
        assertThat(results.get(0).getSummary(), is("class level description"));
        assertThat(results.get(0).getHighlight(), containsString("Application"));
        assertThat(results.get(0).getHighlight(), containsString("Context"));
        assertThat(results.get(0).getOriginalSearchTerm(), equalTo("ApplicationContext"));
    }
View Full Code Here

        assertThat(results.get(0).getOriginalSearchTerm(), equalTo("ApplicationContext"));
    }

    @Test
    public void deleteOldApiDocs() throws ParseException {
        SearchEntry oldApiDoc1 = SearchEntryBuilder.entry()
                .path("http://example.com/content1").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("1.2.3.RELEASE").notCurrent().projectId("project id to delete")
                .type("apiDoc").build();

        searchService.saveToIndex(oldApiDoc1);

        SearchEntry oldApiDoc2 = SearchEntryBuilder.entry()
                .path("http://example.com/content2").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("1.5.3.M1").notCurrent().projectId("project id to delete")
                .type("apiDoc").build();

        searchService.saveToIndex(oldApiDoc2);

        SearchEntry newApiDoc1 = SearchEntryBuilder.entry()
                .path("http://example.com/content3").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("2.0.0.RELEASE").notCurrent().projectId("project id to delete")
                .type("apiDoc").build();

        searchService.saveToIndex(newApiDoc1);

        SearchEntry newApiDoc2 = SearchEntryBuilder.entry()
                .path("http://example.com/content4").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("2.1.0.M1").notCurrent().projectId("project id to delete")
                .type("apiDoc").build();

        searchService.saveToIndex(newApiDoc2);

        SearchEntry nonApiDoc = SearchEntryBuilder.entry()
                .path("http://example.com/content5").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .notCurrent().type("site").build();

        searchService.saveToIndex(nonApiDoc);

        SearchEntry otherApiDoc = SearchEntryBuilder.entry()
                .path("http://example.com/content6").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .notCurrent().projectId("not id to delete").version("3.4.5.RELEASE")
                .type("apiDoc").build();
View Full Code Here

        assertThat(results.size(), equalTo(4));
    }

    @Test
    public void deleteOldReferenceDocs() throws ParseException {
        SearchEntry oldReferenceDoc1 = SearchEntryBuilder.entry()
                .path("http://example.com/content1").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("1.2.3.RELEASE").notCurrent().projectId("project id to delete")
                .type("site").build();

        searchService.saveToIndex(oldReferenceDoc1);

        SearchEntry oldReferenceDoc2 = SearchEntryBuilder.entry()
                .path("http://example.com/content2").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("1.5.3.M1").notCurrent().projectId("project id to delete")
                .type("site").build();

        searchService.saveToIndex(oldReferenceDoc2);

        SearchEntry newReferenceDoc1 = SearchEntryBuilder.entry()
                .path("http://example.com/content3").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("2.0.0.RELEASE").notCurrent().projectId("project id to delete")
                .type("site").build();

        searchService.saveToIndex(newReferenceDoc1);

        SearchEntry newReferenceDoc2 = SearchEntryBuilder.entry()
                .path("http://example.com/content4").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .version("2.1.0.M1").notCurrent().projectId("project id to delete")
                .type("site").build();

        searchService.saveToIndex(newReferenceDoc2);

        SearchEntry nonReferenceDoc = SearchEntryBuilder.entry()
                .path("http://example.com/content5").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .notCurrent().type("site").build();

        searchService.saveToIndex(nonReferenceDoc);

        SearchEntry othersite = SearchEntryBuilder.entry()
                .path("http://example.com/content6").title("ApplicationContext")
                .rawContent("This is an api doc for ApplicationContext.")
                .summary("class level description").publishAt("2013-01-01 10:00")
                .notCurrent().projectId("not id to delete").version("3.4.5.RELEASE")
                .type("site").build();
View Full Code Here

                .andReturn();
        return Jsoup.parse(mvcResult.getResponse().getContentAsString());
    }

    private void createSingleSearchEntry() {
        SearchEntry searchEntry = SearchEntryBuilder.entry()
                .title("This week in Spring - June 3, 2013")
                .summary("Html summary")
                .rawContent("Raw Content")
                .path("/blog/" + 1)
                .build();
View Full Code Here

    private void buildManySearchEntries(int numberToCreate) {
        Calendar calendar = Calendar.getInstance();
        for (int number = 1; number <= numberToCreate; number++) {
            calendar.set(2012, 10, number);

            SearchEntry entry = SearchEntryBuilder.entry()
                    .title("This week in Spring - November " + number + ", 2012")
                    .summary("Html summary")
                    .rawContent("Raw Content")
                    .type("site")
                    .path("/blog/" + number)
View Full Code Here

        assertThat(facets.get(1).getCount(), equalTo(2));
    }

    @Test
    public void unpublishedEntriesDoNotAppearInResultsOrFacets() throws ParseException {
        SearchEntry unpublishedPost = SearchEntryBuilder.entry()
                .path("http://example.com/blog")
                .title("a title")
                .publishAt("2100-12-01 12:32")
                .facetPath("Blog")
                .facetPath("Blog/Engineering").build();
View Full Code Here

TOP

Related Classes of sagan.search.SearchEntry

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.