Package org.elasticsearch.search.highlight

Examples of org.elasticsearch.search.highlight.HighlightBuilder


      int hlsnippets = request.paramAsInt("hl.snippets", 1);
      int hlfragsize = request.paramAsInt("hl.fragsize", 100);
      String hlsimplepre = request.param("hl.simple.pre");
      String hlsimplepost = request.param("hl.simple.post");

      HighlightBuilder highlightBuilder = new HighlightBuilder();
      if (hlfl == null) {
        // run against default _all field
        highlightBuilder.field("_all", hlfragsize, hlsnippets);
      } else {
        String[] hlfls = hlfl.split("\\s|,");
        for (String hlField : hlfls) {
          // skip wildcarded fields
          if (!hlField.contains("*")) {
            highlightBuilder.field(hlField, hlfragsize, hlsnippets);
          }
        }
      }

      // pre tags
      if (hlsimplepre != null) {
        highlightBuilder.preTags(hlsimplepre);
      }

      // post tags
      if (hlsimplepost != null) {
        highlightBuilder.postTags(hlsimplepost);
      }

      searchSourceBuilder.highlight(highlightBuilder);

    }
View Full Code Here


    /**
     * A static factory method to construct new search highlights.
     */
    public static HighlightBuilder highlight() {
        return new HighlightBuilder();
    }
View Full Code Here

        return this;
    }

    public HighlightBuilder highlighter() {
        if (highlightBuilder == null) {
            highlightBuilder = new HighlightBuilder();
        }
        return highlightBuilder;
    }
View Full Code Here

        searchSourceBuilder.facet(facetBuilder);
    }

    private void addHighlights(SearchSourceBuilder searchSourceBuilder) {
        HighlightBuilder highlightBuilder =
                new HighlightBuilder().order("score").requireFieldMatch(false).field("rawContent", 300, 1);

        searchSourceBuilder.highlight(highlightBuilder);
    }
View Full Code Here

      int hlsnippets = request.paramAsInt("hl.snippets", 1);
      int hlfragsize = request.paramAsInt("hl.fragsize", 100);
      String hlsimplepre = request.param("hl.simple.pre");
      String hlsimplepost = request.param("hl.simple.post");

      HighlightBuilder highlightBuilder = new HighlightBuilder();
      if (hlfl == null) {
        // run against default _all field
        highlightBuilder.field("_all", hlfragsize, hlsnippets);
      } else {
        String[] hlfls = hlfl.split("\\s|,");
        for (String hlField : hlfls) {
          // skip wildcarded fields
          if (!hlField.contains("*")) {
            highlightBuilder.field(hlField, hlfragsize, hlsnippets);
          }
        }
      }

      // pre tags
      if (hlsimplepre != null) {
        highlightBuilder.preTags(hlsimplepre);
      }

      // post tags
      if (hlsimplepost != null) {
        highlightBuilder.postTags(hlsimplepost);
      }

      searchSourceBuilder.highlight(highlightBuilder);

    }
View Full Code Here

    /**
     * A static factory method to construct new search highlights.
     */
    public static HighlightBuilder highlight() {
        return new HighlightBuilder();
    }
View Full Code Here

        }
    }

    public HighlightBuilder highlighter() {
        if (highlightBuilder == null) {
            highlightBuilder = new HighlightBuilder();
        }
        return highlightBuilder;
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.highlight.HighlightBuilder

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.