Changes

Jump to navigation Jump to search
795 bytes removed ,  16:19, 5 August 2022
Changes to API
Line 92: Line 92:  
     field: str
 
     field: str
 
     value: str
 
     value: str
     # One of eq, ne, like, without
+
     # One of eq, ne, like
 
     operator: str = 'eq'
 
     operator: str = 'eq'
   Line 99: Line 99:  
     field: str
 
     field: str
 
     value: float
 
     value: float
     # One of eq, ne, lt, gt, without
+
     # One of eq, ne, lt, gt
 
     operator: str = 'eq'
 
     operator: str = 'eq'
   Line 106: Line 106:  
     field: str
 
     field: str
 
     value: datetime.datetime
 
     value: datetime.datetime
     # One of eq, ne, lt, gt, without
+
     # One of lt, gt
 
     operator: str = 'eq'
 
     operator: str = 'eq'
   Line 136: Line 136:  
The remaining APIs have several commonalities:
 
The remaining APIs have several commonalities:
   −
* Only fields with a value are returned in the JSON response, to keep response size down without needing to specify fields manually
   
* An optional ''response_fields'' parameter is provided, to limit the fields in the response further
 
* An optional ''response_fields'' parameter is provided, to limit the fields in the response further
 
* POST is used, to support a complex request body
 
* POST is used, to support a complex request body
Line 144: Line 143:  
* ''like'' operator, which does not need to match to exact fields, but rather will match by use of the [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-snowball-tokenfilter.html snowball token filter] in Elasticsearch if the field supports it.
 
* ''like'' operator, which does not need to match to exact fields, but rather will match by use of the [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-snowball-tokenfilter.html snowball token filter] in Elasticsearch if the field supports it.
 
* ''gt'', ''lt'' (greater than, less than) operators are provided.
 
* ''gt'', ''lt'' (greater than, less than) operators are provided.
* To maintain backwards compatibility, a ''without'' operator is provided, in which case the value will be ignored. Note that the value is still required, so a dummy value should be used (it was feared that making this optional would lead to client side bugs). This should be well documented.
  −
* The without operator will match empty data, as well as the empty string and 0 for numeric fields. This supports queries such as "Get foods without carbohydrates" for backwards comptability, even though that would be better served by making a query where carbohydrates = 0 (ensuring that missing data is not returned in the results).
   
* There is no support for an OR operator (which is supported in the [[Open Food Facts Search API Version 2|V2 API]]), however clients can perform this logic themselves if they wish through multiple API calls.
 
* There is no support for an OR operator (which is supported in the [[Open Food Facts Search API Version 2|V2 API]]), however clients can perform this logic themselves if they wish through multiple API calls.
  
17

edits

Navigation menu