Chirag Jain
Chirag Jain

Reputation: 2418

Elasticsearch: More like this query on multiple index types

We have dataIndex with two types: users and jobs.

users: {
    tags: ['a', 'b'],
    locations: ['NY', 'SF']
    experience: [
        {
            title: 'Software Engineer',
            company: 'abc'
        }
    ]
}

Job: {
    tags: ['a', 'b'],
    location: 'NY',
    title: 'Software Enginner'
}

For a given user we are tying to suggest users and jobs using more_like_this query

User suggestion works fine using below query where id is the userid.

"more_like_this": {
    "fields": ["tags", "locations"],
    "docs": [
      {
        "_index": "dataIndex",
        "_type": "users",
        "_id": id
      }
    ],
}

For jobs we want to query against both jobs and users index. Basically match jobs same as user locations and tags. Is it possible with more_like_this query?

Upvotes: 2

Views: 1240

Answers (1)

Ali
Ali

Reputation: 116

Yes it is. Just don't specify the type... e.g.

GET index_name/_search
{
  "query": {
    "more_like_this": {

Upvotes: 1

Related Questions