Package sagan.search

Examples of sagan.search.SearchEntry


        return blogService.getAllPublishedPosts();
    }

    @Override
    public void indexItem(Post indexable) {
        SearchEntry searchEntry = mapper.map(indexable);
        searchService.saveToIndex(searchEntry);
    }
View Full Code Here


import org.jsoup.Jsoup;

class UnderstandingDocMapper implements SearchEntryMapper<UnderstandingDoc> {
    @Override
    public SearchEntry map(UnderstandingDoc guide) {
        SearchEntry entry = new SearchEntry();
        String rawContent = Jsoup.parse(guide.getContent()).text();
        entry.setRawContent(rawContent);
        entry.setTitle(guide.getSubject());
        entry.setPath("understanding/" + guide.getSubject());
        entry.setSummary(rawContent.substring(0, Math.min(500, rawContent.length())));
        entry.addFacetPaths("Guides", "Guides/Understanding");
        entry.setPublishAt(new Date(0L));
        entry.setSubTitle("Understanding Doc");
        return entry;
    }
View Full Code Here

class TutorialMapper implements SearchEntryMapper<Guide> {

    @Override
    public SearchEntry map(Guide tutorial) {
        SearchEntry entry = new SearchEntry();
        entry.setTitle(tutorial.getTitle());
        entry.setSubTitle("Tutorial");

        String text = Jsoup.parse(tutorial.getContent()).text();

        entry.setSummary(text.substring(0, Math.min(500, text.length())));
        entry.setRawContent(text);
        entry.setPath("/guides/tutorials/" + tutorial.getGuideId() + "/");
        entry.addFacetPaths("Guides", "Guides/Tutorials");
        entry.setPublishAt(new Date(0L));
        return entry;
    }
View Full Code Here

class GuideSearchEntryMapper implements SearchEntryMapper<Guide> {

    @Override
    public SearchEntry map(Guide guide) {
        SearchEntry entry = new SearchEntry();
        entry.setTitle(guide.getTitle());
        entry.setSubTitle("Getting Started Guide");

        String text = Jsoup.parse(guide.getContent()).text();

        entry.setSummary(text.substring(0, Math.min(500, text.length())));
        entry.setRawContent(text);
        entry.setPath("/guides/gs/" + guide.getGuideId() + "/");
        entry.addFacetPaths("Guides", "Guides/Getting Started");
        entry.setPublishAt(new Date(0L));
        return entry;
    }
View Full Code Here

        this.version = version;
    }

    @Override
    public SearchEntry map(Document document) {
        SearchEntry entry = new SearchEntry();
        entry.setPublishAt(new Date(0L));
        String text = document.text();

        entry.setRawContent(text);
        entry.setSummary(text.substring(0, Math.min(500, text.length())));
        entry.setTitle(document.title());
        entry.setSubTitle(String.format("%s (%s Reference)", project.getName(), version.getVersion()));
        entry.setPath(document.baseUri());
        entry.setCurrent(version.isCurrent());
        entry.setProjectId(project.getId());
        entry.setVersion(version.getVersion());

        entry.addFacetPaths("Projects", "Projects/Reference", "Projects/" + project.getName(), "Projects/"
                + project.getName() + "/" + version.getVersion());

        return entry;
    }
View Full Code Here

            apiContent = blocks.text();
        } else {
            apiContent = document.select("p").text();
        }

        SearchEntry entry = new SearchEntry();

        entry.setPublishAt(new Date(0L));
        entry.setRawContent(apiContent);
        entry.setSummary(apiContent.substring(0, Math.min(apiContent.length(), 500)));
        entry.setTitle(document.title());
        entry.setSubTitle(String.format("%s (%s API)", project.getName(), version.getVersion()));
        entry.setPath(document.baseUri());
        entry.setCurrent(version.isCurrent());
        entry.setType("apiDoc");
        entry.setVersion(version.getVersion());
        entry.setProjectId(project.getId());

        entry.addFacetPaths("Projects", "Projects/Api", "Projects/" + project.getName(), "Projects/"
                + project.getName() + "/" + version.getVersion());
        return entry;
    }
View Full Code Here

@Component
class MemberProfileSearchEntryMapper implements SearchEntryMapper<MemberProfile> {
    @Override
    public SearchEntry map(MemberProfile profile) {
        SearchEntry entry = new SearchEntry();
        entry.setTitle(profile.getFullName());
        entry.setSummary(profile.getBio());
        entry.setRawContent(profile.getBio());
        entry.setPath("/team/" + profile.getUsername());
        return entry;
    }
View Full Code Here

        mapper = documentMapper;
    }

    @Override
    public void process(Document document) {
        SearchEntry searchEntry = mapper.map(document);
        if (searchEntry != null) {
            searchService.saveToIndex(searchEntry);
        }
    }
View Full Code Here

class PostSearchEntryMapper implements SearchEntryMapper<Post> {

    @Override
    public SearchEntry map(Post post) {
        SearchEntry entry = new SearchEntry();
        entry.setTitle(post.getTitle());
        entry.setSubTitle("Blog Post");

        String summary = Jsoup.parse(post.getRenderedSummary()).text();
        String content = Jsoup.parse(post.getRenderedContent()).text();

        entry.setSummary(summary);
        entry.setRawContent(content);
        entry.addFacetPaths("Blog", "Blog/" + post.getCategory().getDisplayName());
        entry.setPath("/blog/" + post.getPublicSlug());
        entry.setPublishAt(post.getPublishAt());
        return entry;
    }
View Full Code Here

    @Test
    public void searchOnlyIncludesEntriesMatchingSearchTerm() throws ParseException {
        indexSingleEntry();

        SearchEntry secondEntry =
                SearchEntryBuilder.entry().path("/another/path").title("Test").rawContent("Test body").build();

        searchService.saveToIndex(secondEntry);
        Page<SearchResult> searchEntries =
                searchService.search("content", pageable, Collections.<String> emptyList()).getPage();
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.