2

When you search for “playa parents not working” on http://expressionengine.stackexchange.com, you’re brought to this URL:

https://expressionengine.stackexchange.com/search?q=playa+parents+not+working

Which has 3 results, each relevant to the search terms.

But if you attempt to run a similar search from the API:

https://api.stackexchange.com/2.1/search/advanced?site=expressionengine&q=playa+parents+not+working

…there are at least 31 results (30 are returned, and has_more is true). Looking at the results, it’s clear that the API is returning results where any of the keywords are present, rather than just results that match each of the keywords, like the website.

Is there any way to format the 'q' parameter value so it's treated like the site search? Where all words are included, rather than any?

1 Answer 1

1

The sites are now using a new search implementation, so at least for the time being you should generally expect the results to be quite different. I'm not sure if there are any plans (or if it's otherwise possible) to leverage the new search backend for the API, so I don't know if this will change in the future.

That said, you can force the API search to return results containing certain words by using the + operator (encoded as %2B), which will AND the terms together. Due to the lack of stemming in the search used by the API you still don't get quite the same results (one of the posts uses a variant of "works"), but this request:

https://api.stackexchange.com/2.1/search/advanced?site=expressionengine&q=%2bplaya+%2Bparent+%2Bworks

will at least give you two out of three*.

*which ain't bad

2
  • Thanks! Just to clarify, both a plus sign and the %2B seem to be required, like in your example URL. Just using %2B without the plus sign yields 0 results: api.stackexchange.com/2.1/search/… Jan 8, 2013 at 14:54
  • Right, the unencoded + are just spaces in the search string
    – Tim Stone
    Jan 8, 2013 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .