Monday, August 16, 2010

Sphinx extended query syntax

One advice I should give is about the syntax of query.

I your text-search involves more than one attribute, then you have two choices to build your query like:
1. Query: @attr1 "*keyword*" | @attr2 "*keyword*" | @attr3 "*keyword*"
2. Query: @(attr1|attr2|attr3) "*keyword*"

Now benchmarking:
1st Query, on 1000 iterations, took 23.2s of pure sphinx time
2nd Query, on 1000 iterations, took 16.2s of pure sphinx time.

Make you conclusions... ;)

PS: I also tried 3rd approach:
I made concatenated attribute, named it @attr1_attr2_attr3 in sphinx's configuration file, and query's format was like:
@attr1_attr2_attr3 "*keyword*"... 1000 iterations of this type of query, took 17.9 seconds... much better than 1st one, but still 2nd is better.

No comments:

Post a Comment