Examples of ClusteringActionRequestBuilder


Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

            tasks.add(new Callable<ClusteringActionResponse>() {
                public ClusteringActionResponse call() throws Exception {
                    System.out.print(">");
                    System.out.flush();

                    ClusteringActionResponse result = new ClusteringActionRequestBuilder(client)
                        .setQueryHint("data mining")
                        .addFieldMapping("title", LogicalField.TITLE)
                        .addHighlightedFieldMapping("content", LogicalField.CONTENT)
                        .setSearchRequest(
                          client.prepareSearch()
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

* Java API tests for {@link ClusteringAction}.
*/
public class ClusteringActionTests extends AbstractApiTest {
    @Test(dataProvider = "clients")
    public void testComplexQuery(Client client) throws IOException {
        ClusteringActionResponse result = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .addFieldMapping("title", LogicalField.TITLE)
            .addHighlightedFieldMapping("content", LogicalField.CONTENT)
            .setSearchRequest(
              client.prepareSearch()
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

    public void testAttributes(Client client) throws IOException {
        Map<String,Object> attrs = Maps.newHashMap();
        LingoClusteringAlgorithmDescriptor.attributeBuilder(attrs)
            .desiredClusterCountBase(5);

        ClusteringActionResponse result = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .addFieldMapping("title", LogicalField.TITLE)
            .addFieldMapping("content", LogicalField.CONTENT)
            .addAttributes(attrs)
            .setSearchRequest(
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

        // constants from the descriptor.
        attrs.put(
                MultilingualClusteringDescriptor.Keys.LANGUAGE_AGGREGATION_STRATEGY,
                LanguageAggregationStrategy.FLATTEN_NONE.name());

        ClusteringActionResponse result = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .addFieldMapping("title", LogicalField.TITLE)
            .addFieldMapping("content", LogicalField.CONTENT)
            .addFieldMapping("rndlang", LogicalField.LANGUAGE)
            .addAttributes(attrs)
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

            .contains("stc", "lingo", "kmeans");
    }

    @Test(dataProvider = "clients")
    public void testNonexistentFields(Client client) throws IOException {
        ClusteringActionResponse result = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .addFieldMapping("_nonexistent_", LogicalField.TITLE)
            .addFieldMapping("_nonexistent_", LogicalField.CONTENT)
            .setSearchRequest(
              client.prepareSearch()
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

   
    @Test(dataProvider = "clients")
    public void testNonexistentAlgorithmId(Client client) throws IOException {
        // The query should result in an error.
        try {
            new ClusteringActionRequestBuilder(client)
                .setQueryHint("")
                .addFieldMapping("_nonexistent_", LogicalField.TITLE)
                .setAlgorithm("_nonexistent_")
                .setSearchRequest(
                  client.prepareSearch()
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

    @Test(dataProvider = "clients")
    public void testInvalidSearchQuery(Client client) throws IOException {
        // The query should result in an error.
        try {
            new ClusteringActionRequestBuilder(client)
                .setQueryHint("")
                .addFieldMapping("_nonexistent_", LogicalField.TITLE)
                .setAlgorithm("_nonexistent_")
                .setSearchRequest(
                  client.prepareSearch()
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

            Map<String,Object> attrs = Maps.newHashMap();
            // Out of allowed range (should cause an exception).
            STCClusteringAlgorithmDescriptor.attributeBuilder(attrs)
                .ignoreWordIfInHigherDocsPercent(Double.MAX_VALUE);

            new ClusteringActionRequestBuilder(client)
                .setQueryHint("")
                .addFieldMapping("title", LogicalField.TITLE)
                .addFieldMapping("content", LogicalField.CONTENT)
                .setAlgorithm("stc")
                .addAttributes(attrs)
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

                .setSize(2)
                .setQuery(QueryBuilders.termQuery("_all", "data"))
                .addField("content");

        // with hits (default)
        ClusteringActionResponse resultWithHits = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .setAlgorithm("stc")
            .addFieldMapping("title", LogicalField.TITLE)
            .setSearchRequest(req)
            .execute().actionGet();
        checkValid(resultWithHits);
        checkJsonSerialization(resultWithHits);
        // get JSON output
        XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
        builder.startObject();
        resultWithHits.toXContent(builder, ToXContent.EMPTY_PARAMS);
        builder.endObject();
        JSONObject jsonWithHits = new JSONObject(builder.string());
        Assertions.assertThat(jsonWithHits.has("hits")).isTrue();

        // without hits
        ClusteringActionResponse resultWithoutHits = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .setIncludeHits("false")
            .setAlgorithm("stc")
            .addFieldMapping("title", LogicalField.TITLE)
            .setSearchRequest(req)
View Full Code Here

Examples of org.carrot2.elasticsearch.ClusteringAction.ClusteringActionRequestBuilder

                .setSize(2)
                .setQuery(QueryBuilders.termQuery("_all", "data"))
                .addField("content");

        // Limit the set of hits to just top 2.
        ClusteringActionResponse limitedHits = new ClusteringActionRequestBuilder(client)
            .setQueryHint("data mining")
            .setMaxHits(2)
            .setAlgorithm("stc")
            .addFieldMapping("title", LogicalField.TITLE)
            .setSearchRequest(req)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.