Hacker News new | ask | show | jobs
by xiekomb 2170 days ago
Hi,

Simple and effective API. The documentation lacks details about the query parameter. I want to search for A AND B but q=?A%20B does not yield the expected result (seems a OR query) or for exact phrase "A invests in B" do not seem to work. Can you please post details for advanced syntax like this?

1 comments

Hi, thanks for the feedback! So far, I haven't implemented this feature yet. The query parameter gets tokenized as is, and then tokens are used to search in the index. Could you provide more details about your use case? As I understand you need to have AND, OR, NOT, grouping () operators, anything else? I would try to implement this today, and write back to you.
yes this is exactly what I (most users?) would need. Search for exact phrase would be a plus also. Eg: "donald trump" instead of Donald AND trump. What kind of backend are you using, a simple database or search index like elasticsearch (which would be more appropriate for such project)?
Hi, just finished implementing this stuff. To search a AND b use 'q=A+B'. Here are a few examples:

> curl -XGET -G 'api.datanews.io/v1/news' -d 'apiKey=API_KEY' --data-urlencode 'q="Europe throws new rule book at Google, tech giants to loosen market grip"'

> curl -XGET -G 'api.datanews.io/v1/news' -d 'apiKey=API_KEY' --data-urlencode 'q=google+facebook+amazon'

Supported operators:

+ AND, | OR, - NOT, () parentheses for grouping, "" exact match

EDIT: examples

Kudos!