basho/riak_search — pull request #91 by rustyio (2011-10-12 16:55:05+00:00)
Title: Fix exact phrase searching with repeated terms (AZ847, BZ1225)

Rewrote and simplified exact phrase and proximity matching logic to correctly handle exact phrase searches with repeated terms. Added unit tests around the tricky bits.

To test:

```bash
# Install the search hook on bucket 'books'.
bin/search-cmd install books

# Load some data...
curl -X POST \
-d "one fish two fish red fish blue fish" \
localhost:8098/riak/books/book1

curl -X POST \
-d "see spot see spot run" \
localhost:8098/riak/books/book2

curl -X POST \
-d "it was the best of times it was the worst of times" \
localhost:8098/riak/books/book3

# This used to fail, now it successfully finds a result...
bin/search-cmd search books "\"one fish two fish\""

# Some positive tests...
bin/search-cmd search books "fish"
bin/search-cmd search books "\"one fish\""
bin/search-cmd search books "\"one fish two fish\""
bin/search-cmd search books "\"one fish two fish\" OR \"see spot see spot\""
bin/search-cmd search books "\"one two red blue\"~8"
bin/search-cmd search books "\"one two red blue\"~8 OR \"see run\"~3"

# Some negative tests (ie: these are expected to return zero results)
bin/search-cmd search books "fish AND foo"
bin/search-cmd search books "\"fish one\""
bin/search-cmd search books "\"one fish fish two\""
bin/search-cmd search books "\"one fish fish two\" OR \"see spot spot see\""
bin/search-cmd search books "\"one two red blue\"~6"
bin/search-cmd search books "\"one two red blue\"~6 OR \"see run\"~2"
```