Search a specific document?


(A Zed) #1

Is it possible to run a query against a specific document? I have the doc
ID and the query; I'd like to just query that document.

Thanks!

--


(A Zed) #2

Actually, let me clarify: I just want the terms highlighted in the
document, if there's a match.
I could do it via JS in the client, but maybe ES is faster....

On Friday, December 7, 2012 12:59:26 PM UTC-8, A Zed wrote:

Is it possible to run a query against a specific document? I have the doc
ID and the query; I'd like to just query that document.

Thanks!

--


(Igor Motov) #3

Have you seen highlighting option in Search API
http://www.elasticsearch.org/guide/reference/api/search/highlighting.html ?

On Friday, December 7, 2012 4:04:18 PM UTC-5, A Zed wrote:

Actually, let me clarify: I just want the terms highlighted in the
document, if there's a match.
I could do it via JS in the client, but maybe ES is faster....

On Friday, December 7, 2012 12:59:26 PM UTC-8, A Zed wrote:

Is it possible to run a query against a specific document? I have the doc
ID and the query; I'd like to just query that document.

Thanks!

--


(A Zed) #4

Yes I have. If I am able to search a specific doc, then I can use the
highlight option too.

On Friday, December 7, 2012 1:56:09 PM UTC-8, Igor Motov wrote:

Have you seen highlighting option in Search API
http://www.elasticsearch.org/guide/reference/api/search/highlighting.html?

On Friday, December 7, 2012 4:04:18 PM UTC-5, A Zed wrote:

Actually, let me clarify: I just want the terms highlighted in the
document, if there's a match.
I could do it via JS in the client, but maybe ES is faster....

On Friday, December 7, 2012 12:59:26 PM UTC-8, A Zed wrote:

Is it possible to run a query against a specific document? I have the
doc ID and the query; I'd like to just query that document.

Thanks!

--


(Igor Motov) #5

How about ids
filter? http://www.elasticsearch.org/guide/reference/query-dsl/ids-filter.html

On Friday, December 7, 2012 4:58:40 PM UTC-5, A Zed wrote:

Yes I have. If I am able to search a specific doc, then I can use the
highlight option too.

On Friday, December 7, 2012 1:56:09 PM UTC-8, Igor Motov wrote:

Have you seen highlighting option in Search API
http://www.elasticsearch.org/guide/reference/api/search/highlighting.html?

On Friday, December 7, 2012 4:04:18 PM UTC-5, A Zed wrote:

Actually, let me clarify: I just want the terms highlighted in the
document, if there's a match.
I could do it via JS in the client, but maybe ES is faster....

On Friday, December 7, 2012 12:59:26 PM UTC-8, A Zed wrote:

Is it possible to run a query against a specific document? I have the
doc ID and the query; I'd like to just query that document.

Thanks!

--


(pellyadolfo) #6

According to what has been said in this thread to fetch only one document,
I have tested the following query trying to highlight just one document:

SearchResponse response2 = getClient().prepareSearch()
.setIndices("myindex")
.setTypes("mytype")
.setQuery(QueryBuilders
.boolQuery()
.should(QueryBuilders.matchQuery("2C", "house"))
)

  • .setFilter(FilterBuilders.idsFilter("ve0"))*
    .addHighlightedField("2C", 250, 1)
    .execute()
    .actionGet();

System.out.println("Returned " + response2.getHits().getTotalHits() + "
results");

However, the query produces zero results.

By commenting out the line

*//.setFilter(FilterBuilders.idsFilter("ve0")) *

10 results are generated as expected.

The id specified is correct. So, is it a bug or a misuse of idsFilter()?

Thanks

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/411fda5b-d0d3-41dd-9867-cfac05e49560%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(pellyadolfo) #7

I have just got my answer from fix to this bug

which contains a TestCase

where proper syntax is:

.setFilter(FilterBuilders.idsFilter("vertex").ids("ve0"))

and document is now returned.

Thanks

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3cd7f32a-3989-45ea-ad42-96ad5307e10b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #8