PDA

View Full Version : How To Search Based On Order Of Words In A Sentence?


cnewtonne
02-10-2011, 09:19 AM
My urd db has FTS enabled. I'm trying to search based on the order of words e.g.
1) Item 1 text contains "my name is cnewtonne".
2) Item 2 text contains "cnewtonne is my name"

I want to search so that it only returns the item where "cnewtonne" APPEARS AFTER "name"

I tried the following search phrases, but none worked ...

- name NEAR cewntonne: returns both.
- name .* cnewtonne: both
- "name is cnewtonne": returns first, but I can not always tell what and how many words are between 'name' and 'cnewtonne'
- Also, for the search work NEAR, how near is near?

Thank you.

kinook
02-10-2011, 10:24 AM
Search for

*name * newtonne*

NEAR searches are within 10 words by default, which can be modified like this:

newtonne NEAR/5 name

See here for more details on FTS search syntax (there is a section on NEAR queries): http://www.sqlite.org/fts3.html

cnewtonne
02-10-2011, 01:38 PM
This is good.
I see that NEAR does not honor order ...

So, search phrase 'one NEAR two' returns both of these ...

one comes before two
two comes after one


Also, phrase '*one * two*' returns

one comes before two
and
one is too far ... ... ... ... ...x100 from two (... represents 100 lines of text)
but NOT
two comes after one

So ...
Is there a way to have both effects. i.e. have NEAR and order together so it only returns

one comes before two


Thank you.

kinook
02-10-2011, 01:48 PM
Try an advanced search with

name NEAR newtonne

in 'Search for' and

(Item) matches wildcard *name * newtonne*

in the grid.