1

I've got problem with nested query.

My model looks like that:

public class Car
{
    public int Age {get; set;}  
    public List<User> Users {get; set;}

}

public class User
{
    public List<string> Names {get; set;}
    public List<string> Surnames {get; set;}

}

It can't be modify.

and my object looks like:

{
  "age": 12,
  "users": [
    {
      "names": [
        "Adam",
        "Bob"
      ],
      "surnames": [
        "xyz",
        "abc"
      ]
    }
  ]
}

How should look code to find car whose user is Bob? I know that example is not very good, but it shows central point of my problem.

1
  • It is not clear what exactly you want ? You need the list of the car whose user name is Bob? Commented Dec 19, 2017 at 17:31

1 Answer 1

1
var result1 = await _ec.SearchAsync<Car>(s => s.Query(q => q.Term(t => t.Field("users.names").Value("Bob"))));
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.