1

I have index define like this

    {
      "mappings": {
        "my_mapping1": {
          "dynamic": false,
          "_all":       { "enabled": false },
          "_source":    { "enabled": false },
          "properties": {
              "my_property1":      { "type": "long", "store": true },
          }
        },
        "my_mapping2": {


    query = QueryBuilders.matchQuery("my_property1", "123123");


    Set<String> queryIndices = new HashSet<>();
    queryIndices.add("my_index_name");

    SearchResponse searchResponse = searchBuilder(SearchType.DFS_QUERY_THEN_FETCH, query, fields,
            queryIndices.toArray(new String[queryIndices.size()]), params.getType())
            .setSize(size)
            .execute().actionGet();

How do I specify that I am searching on my_mapping1 and not my_mapping2

And follow up question, does matchQuery's type matter like instead of string should i query with long object?

0

1 Answer 1

1

By looking at your source, it looks like you are not using the official java high-level rest client(JHLRC) which is available from 6.0

Please refer to the official search request API using JHLRC, where under the optional argument section it's explained how to pass the types name, in your case my_mapping1 and my_mapping2.

SearchRequest searchRequest = new SearchRequest("posts"); 
searchRequest.types("doc"); // here you need to pass your type name.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.