Closed isuftin closed 7 years ago
That search doesn't do what you think anyway, TO
ranges in Lucene operate on text ranges, not numeric ranges. Chef does not support numeric range searches.
@coderanger Seems that it does operate on numbers: https://brettscott.wordpress.com/2011/11/19/lucene-number-range-search-integers-floats/
@coderanger When doing the search via knife search node, I do get the correct data back that I expect. Example knife search node "ohai_time:[0 TO 148847433]"
Also figured out my own issue. It was not due to escaping. I had lower-case to
.
len(chef.Search('node', q="ohai_time:[0 TO 148847433]"))
2
Perfect!
Just as long as you are aware that won't always do what you want :-) I would highly recommend implementing the filter in Python code if it is something important.
@coderanger Mainly, I'm looking to not get all nodes (and node info) back from the Chef server each time I run a search. I could just run Search('node') and then parse through that via python but I'd rather use the server's back-end to do the searching for me.
My code here is just the first step in a node sweeping process. Step two would take each item in that list and check if the machine is still running, so there is that safety ;)
👍
Looks like searching with
[ ]
for ranges fails. Assuming it's an escaping issue. Works if I manually escape.PyChef 0.3.0 Python 2.7.13 on CentOS
Working:
Not working: