REST API foods.search with multi terms

200 views
Skip to first unread message

Joe Smith

unread,
Feb 12, 2012, 4:26:43 PM2/12/12
to FatSecret Platform API
Hi,

Thanks for making this wonderful API available for a free trial!

I've seen this asked in the past on the group but did not see an
answer, so I thought I'd give it a try.

It appears that for multiple search terms such as "creamy peanut
butter", the web UI search is working well for finding matches but the
REST API behavior is not producing good matches. I double checked and
I'm encoding the URL correctly.

"blueberry pie" worked by finding blueberry pie entries first (both
terms matched) and then blueberry or pie following that,
though blueberry pie filling was at the end instead of beginning

"peanut butter jif" has 997 REST API hits, but 11 accurate web UI hits

"creamy peanut butter" has 191 REST API hits, but one of the top three
hits is the Jif brand. However, there are 203
web UI hits though Jif is near the top again.

"subway italian" on the REST API returns 15 hits, none of which are
Subway restaurant hits, but on the web UI you get 7
Subway restaurant italian food hits (all good matches).

It appears the REST API generally uses "OR" or some kind of multi-pass
substring search with porter stemming applied, but it clearly is not
able to produce good matches consistently with multiple terms.

Do you have any tips, documentation, or hints on how we can use the
search API more effectively? Is the premium API's search function
able to handle multiple terms more effectively?

Thanks!

John

unread,
Feb 13, 2012, 9:26:47 PM2/13/12
to FatSecret Platform API
Hi Joe,

Search results should largely be the same.

Please note that results may vary by the user so this may be the cause
of the differences you’re seeing.


John
The FatSecret Platform Team

Joe Smith

unread,
Feb 16, 2012, 12:01:13 PM2/16/12
to FatSecret Platform API
John,

Thanks for the reply and point about search results being influenced
by the user logged on. However in all my test cases using both the
web UI and REST API, I was not submitting user credentials and was not
logged in to the web site.

I'm glad you agree that the results should be largely the same between
the REST API and web UI. The web UI search is excellent for ranking
good matches at the top of the search results. I am finding that not
to be the case in my limited testing with the REST API. Would you be
willing to look into some of the test cases I've mentioned in my prior
posting?

The search functionality is the most critical feature of the REST
API. Without it, users cannot locate their food and would not make
use of the remaining features. I do think the search functionality is
misbehaving in some cases and urge you to investigate.

Thanks in advance for any support you are able to provide. If you'd
like me to identify more test cases, I will do that.

John

unread,
Feb 21, 2012, 5:37:01 PM2/21/12
to FatSecret Platform API
I've run the search on both the web and REST API and found the results
identical for all the search examples you've mentioned:

"creamy peanut butter", "blueberry pie", "peanut butter jif" and
"subway italian".

There is something going on with the way you are running the REST API
food search.

Could you try running the search against a known oauth test client and
make sure you do not pass in the "oauth_token" parameter.

Joe Smith

unread,
Mar 16, 2012, 2:56:06 PM3/16/12
to FatSecret Platform API
John,

I was encoding the URL twice, which caused the server to fail to see
the space separating multiple search terms. Having fixed that, the
REST API and web site searches are returning exactly the same number
of results, as you said they would. Thanks for the support, and sorry
about the stupid mistake.
Reply all
Reply to author
Forward
0 new messages