Specify search preference with Python API

Hi,

I am an ES novice and I would be thankful if anyone would help with my 'silly' question.
How can I set my search preference using Python API ? Specifically, I need to specify the shard at each request. I can't find any example around..
What I am looking exactly to do is what "slice" does, but since I 'am working on 1.7 it's not available.

Many thanks,
S

Hey,

search preference is not doing what the sliced scroll does. You still need to use a scroll request on 1.7 and live with less performance than a sliced scroll unless you upgrade (which you now have a great reason to! :slight_smile:

--Alex

Thanks for your reply Alex.

Actually this is exactly what I was doing, scrolling over each shard in order to simulate the sliced scroll though a slice == a shard is the finest (smallest) I can get.
I have already found the syntax for the python API and here's and example for doing a scroll over shard number 2:

esObj.search(index=esIndex, doc_type= esTypeName, scroll = scrollTimeout, search_type = 'scan', size = scNum, preference = "_shards:2", body = queryJson)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.