treflehq / trefle-api

🍀 Trefle is a botanical JSON REST API for plants species, allowing you to search and query over all the registered species, and build the next gardening apps and farming robots.
https://trefle.io
GNU Affero General Public License v3.0
482 stars 50 forks source link

"filter_not" not working properly #63

Closed TedCha closed 3 years ago

TedCha commented 3 years ago

First off, I want to say thank you for all the hard work you guys are putting into this service. It's absolutely awesome!

Describe the bug When using the filter_not parameter to filter out attributes that are null, results will still appear with those null attributes.

To Reproduce Steps to reproduce the behavior:

Using Python and requests library:

  1. Query something with an attribute set in the filter_not parameter (in this case days_to_harvest):
    
    import requests
    import json

r = requests.get(f"https://trefle.io/api/v1/plants/search?token={API_KEY}&q=pineapple&filter_not[days_to_harvest]")

with open("test_json_data.json", "w") as f: json.dump(r.json(), f, indent=4)


2. From the output JSON data, I took the slug of the first result: `ananas-comosus` and plugged it back into another request:
```python
import requests
import json

r = requests.get(f"https://trefle.io/api/v1/plants/ananas-comosus?token={API_KEY}")

with open("test_json_data.json", "w") as f:
    json.dump(r.json(), f, indent=4)
  1. Check the output JSON data and see that for this result, days_to_harvest is null.

Expected behavior I expected the days_to_harvest attribute to not be null as the result for ananas-comosus was in the query searching for results that had this field as not null.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context I might be querying the wrong API endpoint, if so apologies for the post. I can't find anywhere in the documentation how to do this correctly!

lambda2 commented 3 years ago

Hey @tcharts-boop, days_to_harvest is not a filterable/rangeable field yet, but we'll add it !

TedCha commented 3 years ago

Understood. Thank you again!