Searching

Searching is self-explanatory. We search for some words in an index of documents. Let's see how it's done in more detail.

Via the Interface

The easiest way to search is to use the Wuha search interface. This allows you to test the relevance of your search engine without writing any code.

Search for "business plan" and press Enter. You'll see your results directly in the interface.

Via the API

Of course, you'll probably want to put your search engine in front of your users. To do that, you'll need to use the search API in Wuha.

Searching with the API is simple. Again, don't forget to replace your_index_id with the ID of the index you've created.

POST http://localhost:8201/search/your_index_id
{
  "query": "business plan"
}

and the equivalent in cURL:

curl \
  -X POST \
  --header "Content-Type: application/json" \
  --data '{ "query": "business plan" }' \
  http://localhost:8201/search/your_index_id

You'll receive a response from the server similar to:

{
  "numberOfResults": 3,
  "totalResults": 10,
  "results": [
    {
      "id": "213",
      "title": "Business Plan February 2018"
    }
  ]
}

Last updated