Searching multifield with nested object not working in the nested object

Hi,

I'm using Elastic 7.9.2 with ECK 1.2.1. Using Java and Spring too.

I'm trying to query a nested object directly to the id variable(inside the 2nd object) but it always returns zero results.

An example of my mapping, model_objects is the nested object:

"mappings": {
    "properties": {
      "id": {
        "type": "keyword"
      },
      "date": {
        "type": "long"
      },
      "user_id": {
        "type": "keyword"
      }
      "model_objects": {
        "type": "nested",
        "properties": {
          "id": {
            "type": "keyword"
          },
          "name": {
            "type": "keyword",
            "index": false
          }
       }
    }
}

Then this will map to this objects:

public class MessageFromCore {
    private String id;
    private long date;
    private String user_id;
    private List<ModelObjects> model_objects;
}

and

public class ModelObjects {
    private String id;
    private String name;

    public ModelObjects(String id, String name) {
        this.id = id;
        this.name = name;
    }
}

This is indexing and working good for almost everything even search on other parameters except, when I try to search for objects that have a given id to search inside the model_objects, then it always returns an empty response.
The part of the search that is not working is this:

if (messageFromFront.getModel_id() != null) {
   ((BoolQueryBuilder) qb).must(QueryBuilders.termsQuery("model_objects.id", messageFromFront.getModel_id()));
}
//getModel_id() returns a List<String>

This QueryBuilders should work like this according to the documentation or I didn't understand or I'm not seeing something.

I have other QueryBuilders in the same method in other ifs to add to the query and all work together and simultaneously except when I put a model_objects to be searched.

I tried to search for other ways and couldn't find anything that works for me.

Let me know if I need to provide anything else that could help me solve this.
Thank you
Diogo

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.