Elasticsearch-dsl-py: How to select specific fields in search query

Created on 19 Nov 2015  Â·  12Comments  Â·  Source: elastic/elasticsearch-dsl-py

Support is there on Elasticsearch https://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-request-fields.html

how to do the same with elasticsearch-dsl-py ??

Most helpful comment

It was changed to .source

All 12 comments

@vi3k6i5

from elasticsearch_dsl import search
search.Search().fields(['fielda', 'fieldb'])

search.Search().partial_fields(foo={
        'include': ['foo.bar.*'],
        'exclude': ['foo.one']
    })

https://github.com/elastic/elasticsearch-dsl-py/blob/master/test_elasticsearch_dsl/test_search.py#L352
https://github.com/elastic/elasticsearch-dsl-py/blob/master/test_elasticsearch_dsl/test_search.py#L393

Thanks man. It's not there in the documentation any where. We should add it i guess ?

Its there, look at this doc

http://elasticsearch-dsl.readthedocs.org/en/latest/

and search for this text:

"# fields that should be searched"

On Thu, Nov 19, 2015 at 2:38 PM, Vikash Singh [email protected]
wrote:

Thanks man. It's not there in the documentation any where. We should add
it i guess ?

—
Reply to this email directly or view it on GitHub
https://github.com/elastic/elasticsearch-dsl-py/issues/302#issuecomment-157995630
.

Warm Regards!
Amit Pandita
+91-9650308350

@apandita no its not there. The issue i raised is not how to search in a particular field. It's rather how do i specify which fields to be returned in from elasticsearch-dsl. That piece is missing from the documentation.

@Vikash When you pass an array of fields to the search, the result will
always be only those specific fields.

The link i pointed out was not really a direct reference but like a hint to
pick up how to filter fields.

On Thu, Nov 19, 2015 at 2:58 PM, Vikash Singh [email protected]
wrote:

@korkmaz https://github.com/korkmaz @apandita
https://github.com/apandita : One question off this topic. I want
elasticsearch-dsl to track_score.
Basically this feature:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores
Any idea how to do that?
PS: let me know if i should be opening another issue for it.
Thanks :)

—
Reply to this email directly or view it on GitHub
https://github.com/elastic/elasticsearch-dsl-py/issues/302#issuecomment-158000700
.

Warm Regards!
Amit Pandita
+91-9650308350

@apandita : This is what is missing in the document:
search.Search().fields(['fielda', 'fieldb'])
That fields calls. its no where there. I Feel it should be added to the documentation. Let me know how i can help so this gets added to the documentation.
Thanks :)

@honza is the right guy to take a call on this :)

On Thu, Nov 19, 2015 at 3:06 PM, Vikash Singh [email protected]
wrote:

@apandita https://github.com/apandita : This is what is missing in the
document:
search.Search().fields(['fielda', 'fieldb'])
That fields calls. its no where there. I Feel it should be added to the
documentation. Let me know how i can help so this gets added to the
documentation.
Thanks :)

—
Reply to this email directly or view it on GitHub
https://github.com/elastic/elasticsearch-dsl-py/issues/302#issuecomment-158003609
.

Warm Regards!
Amit Pandita
+91-9650308350

@apandita You got the wrong Honza :) cc @HonzaKral

Thanks for bringing this up, I added a section in the docs.

@HonzaKral can you please share your commit id or merge id or some link. So i can directly see the changes you made (What changes you made and where exactly). I want to understand how you guys maintain documents so i can help as well :)

The commit is tagged with this issue so you can see the link above, it's https://github.com/elastic/elasticsearch-dsl-py/commit/fab2f6bf4d665d776afcc47c8f796d51bbab78e8

Any help would be greatly appreciated!

It was changed to .source

Was this page helpful?
0 / 5 - 0 ratings

Related issues

primoz-k picture primoz-k  Â·  4Comments

njoannin picture njoannin  Â·  3Comments

beanaroo picture beanaroo  Â·  4Comments

berinhard picture berinhard  Â·  3Comments

leoliuxd picture leoliuxd  Â·  4Comments