0
votes

I have an ElasticSearch instance indexing a MongoDB database using the river by richardwilly98

There are two types of documents that are indexed:

  • documents referencing users
  • documents representing users

When these objects are added to mongodb richardwilly98's river generates something like the following:

  • document = {'user': {"$id" : "5159a004c87126641f4f9530" } }
  • user_document = {'_id':"5159a004c87126641f4f9530",'username':'bob'}

If I perform a search for 'bob' i'd like any documents that reference the bob document to be returned. At the moment this doesn't happen because the username field is not related to the referencing documents in anyway.

Is it possible to do this? Does ElasticSearch have object references?

Thanks - let me know if I haven't been clear.

2

2 Answers

2
votes

If each document belong to no more than one user, you can index documents as children of users. Then you can use has_parent filter to perform the search. However, if a single document can belong to more than one user, you will have to perform search in two steps. First you would have to find the user and then issue another search to find documents.

1
votes