Search for parts of a string array in elasticsearch

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Search for parts of a string array in elasticsearch

vipins
Hi,

I have a requirement, where i have to search for the filed values(value1,value2 and value3) from elasticsearch.

But these values will be available from three differetn documents.

How can i make a ES query?

Currently i have single value for the filed and the query goes as below;

boolQueryBuilder.must(QueryBuilders.matchQuery(fieldName,
                   value);

How shud i modify the query to suppor the array of string values selection.

Thanks,
Sumitha.
Reply | Threaded
Open this post in threaded view
|

Re: Search for parts of a string array in elasticsearch

Anusha
Hi,

You can use terms query to match N number of values in field in different documents by,

{
    "terms" : {
        "field" : [ "value1", "value2", "value3" ],
        "minimum_should_match" : 3
    }
}

Here you can specify minimum should match,
if you want only only value matched docs then 1 or else to match all the values matched docs keep as 3 or else only 2 values then keep 2.


On Wednesday, June 10, 2015 at 1:31:54 PM UTC+5:30, Vipin Sudhakar wrote:
Hi,

I have a requirement, where i have to search for the filed
values(value1,value2 and value3) from elasticsearch.

But these values will be available from three differetn documents.

How can i make a ES query?

Currently i have single value for the filed and the query goes as below;

boolQueryBuilder.must(QueryBuilders.matchQuery(fieldName,
                   value);

How shud i modify the query to suppor the array of string values selection.

Thanks,
Sumitha.




--
View this message in context: <a href="http://elasticsearch-users.115913.n3.nabble.com/Search-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Felasticsearch-users.115913.n3.nabble.com%2FSearch-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHVur-xfs8SnKrJAxhMcNOCvgEB8g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Felasticsearch-users.115913.n3.nabble.com%2FSearch-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHVur-xfs8SnKrJAxhMcNOCvgEB8g';return true;">http://elasticsearch-users.115913.n3.nabble.com/Search-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/
---
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/78cd197d-d1cf-4891-a2b2-456aec1d8f1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Search for parts of a string array in elasticsearch

Anusha
This will be the equivalent API..

        boolQueryBuilder.must(QueryBuilders.termsQuery("field", "value1","value2","value3").minimumMatch(3));


On Friday, June 12, 2015 at 6:02:31 PM UTC+5:30, Muddadi Hemaanusha wrote:
Hi,

You can use terms query to match N number of values in field in different documents by,

{
    "terms" : {
        "field" : [ "value1", "value2", "value3" ],
        "minimum_should_match" : 3
    }
}

Here you can specify minimum should match,
if you want only only value matched docs then 1 or else to match all the values matched docs keep as 3 or else only 2 values then keep 2.


On Wednesday, June 10, 2015 at 1:31:54 PM UTC+5:30, Vipin Sudhakar wrote:
Hi,

I have a requirement, where i have to search for the filed
values(value1,value2 and value3) from elasticsearch.

But these values will be available from three differetn documents.

How can i make a ES query?

Currently i have single value for the filed and the query goes as below;

boolQueryBuilder.must(QueryBuilders.matchQuery(fieldName,
                   value);

How shud i modify the query to suppor the array of string values selection.

Thanks,
Sumitha.




--
View this message in context: <a href="http://elasticsearch-users.115913.n3.nabble.com/Search-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Felasticsearch-users.115913.n3.nabble.com%2FSearch-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHVur-xfs8SnKrJAxhMcNOCvgEB8g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Felasticsearch-users.115913.n3.nabble.com%2FSearch-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html\46sa\75D\46sntz\0751\46usg\75AFQjCNHVur-xfs8SnKrJAxhMcNOCvgEB8g';return true;">http://elasticsearch-users.115913.n3.nabble.com/Search-for-parts-of-a-string-array-in-elasticsearch-tp4075074.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/
---
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fecfa130-7d2a-492d-b86e-9c782d8f40ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.