2
votes

I dont know if elastic search have poor documentation or i am just searching in the wrong places. The thing i am trying to do is that i want to search a specific index but different type with different quires but one result back. for example:

I have an index called beta and two types inside the index test1 and test2, i want to query the two types with one query:

type test1

 {
        "query": {
            "fuzzy_like_this": {
                "fields": ["LastEditorID"],
                "like_text": "Test1",
                "min_similarity": 0.1,
                "max_query_terms": 5
            }
        }
    }

type test2

{
    "query": {
        "fuzzy_like_this": {
            "fields": ["LastEditorID"],
            "like_text": "Test2",
            "min_similarity": 0.1,
            "max_query_terms": 5
        }
    }
    }

and get the results in one peace I mean one object.I also prefer to specify the type in the query no in the GET request

I am new to elastic search so please anymore just ask.

UPDATE: what i need is something like this but that doesn't work

[{
    "query": {
        "fuzzy_like_this": {
            "fields": ["user"],
            "like_text": "Haider",
            "min_similarity": 0.1,
            "max_query_terms": 5
        }
    },
    "filter": {
        "type": {
            "value": "typetest"         
        }
    }
},
{
    "query": {
        "fuzzy_like_this": {
            "fields": ["user"],
            "like_text": "Haider",
            "min_similarity": 0.1,
            "max_query_terms": 5
        }
    },
    "filter": {
        "type": {
            "value": "typetest"         
        }
    }
}

]
1

1 Answers

2
votes

You can add a filter to your query and filter on _type field.

Does it help?