Query syntax

The following special operators and modifiers can be used when using the extended matching mode:

  • operator OR:
    hello OR world
  • operator AND:
    hello AND world
  • operator NOT:
    hello NOT world
  • field search operator:
    title: hello text: world
  • phrase search operator:
    "hello world"
curl \
    -u :mykey \
    http://appname.api.houndsleuth.com/v1/indexes/indexname/search?q=coffee+OR+tea+city:paris

Geolocation

Geolocation allows you to limit searches by geographic distance. To use geolocation, add location data to your documents by saving them as a latitude/longitude tuple.

curl \
    -X PUT \
    -H "Content-Type: application/json" \
    -u :mykey \
    -d '{"docid":1,"fields":{"text":"blah", "mylocation":[30.2669,-97.7428]}' \
    http://appname.api.houndsleuth.com/v1/indexes/indexname/docs

To query for geolocation data, use the distance function in your scoring function:

distance(mylocation, geopoint(30.2669, -97.7428))

The distance function will sort documents by their proximity to the given coordinate. You may use query variables in your scoring function as usual:

distance(mylocation, geopoint(q[0], q[1]))

To store a new scoring function use the usual API method:

curl \
    -X PUT \
    -H "Content-Type: application/json" \
    -u :mykey \
    -d '{"definition":"distance(mylocation, geopoint(q[0], q[1]))"}' \
    http://appname.api.houndsleuth.com/v1/indexes/indexname/functions/0

Now sort results by distance from the values passed in:

curl \
    -u :mykey \
    -G -d "q=burgers" -d "var0=30.2669" -d "var1=-97.7428"
    http://appname.api.houndsleuth.com/v1/indexes/indexname/search

Scoring matches

To score matches you must define a scoring function in the index console. You may specify an unlimited number of scoring functions. To use a specific scoring function use the function parameter for the search query.

There are the following functions are available in a scoring function:

max(x,y)
the max of x and y
min(x,y)
the min of x and y
*, /, +, -
Arithmetic operators

To use a document variable in the function:

max(doc.var[0], 10)

To use a query variable in the function:

min(query.var[0], index_field_name)

Pre-defined values in a query:

relevance
the TF*IDF relevance value
age
how old the document is in seconds since Jan. 1, 2011

Filtering

Searches can be filtered by category values.

Filtering a search is done by specifying the attribute to filter and the value to set the filter to. Only integer and float attributes can be filtered. Specify the category filters in the format:

category_filters=category1:(Brown OR Black),category2:Hot

Notes

HoundSleuth uses a completely different implementation to provide full-text search than IndexTank. Our implementation has several advantages and some disadvantages.

Advantages

  • Indexes are light weight - it takes no time to create and index and they are available immediately. This allows for much more latitude as you design your application. For instance: testing indexes that are created on demand and even tricks like having an index for each user are now viable options.
  • More scoring functions and variables - our engine allows for any number of scoring functions and any number of document and query variables.
  • Unparalleled Scalability - HoundSleuth's distributed system allows for billions of documents and hundreds of requests per second.

Disadvantages

  • Faceting pulls counts only from returned documents (we are developing a solution to this in the near future).