Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Google-like queries in FoxPro apps
Message
 
To
06/05/2002 16:49:35
Rick Graves
Advanced Approach Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00624182
Message ID:
00656201
Views:
23
For my keyword table, the reason I did not drop any words from the phrase and tacked them on the end is because I do not know what the user might type in. I will expand my earlier example a little, let me know if my logic is sound.
iKey	cData
----	-----
1 	mouse pez frame compaq
1	pez frame compaq mouse
1	frame compaq mouse pez
1	compaq mouse pez frame

2	drive compaq file xml mouse
2	compaq file xml mouse drive
2	file xml mouse drive compaq
2	xml mouse drive compaq file
2	mouse drive compaq file xml

3	frame mouse ring 
3	mouse ring frame
3	ring frame mouse
User can enter "mouse AND frame" and get iKey=1 and iKey=3. This is because I SQL-Select Where cData like "mouse%" and only want top 500 rows, so I get 1,2,3. Then I SQL-Select Where cData like %frame% and get iKey 1,3. Then I SQL-Select for cData="frame%" and get 1,3. Then I SQL-Select Where cData like %mouse% and get 1,3. I do a last SQL-Select and group by iKey and just get back 1 row per iKey value and get 1,3. It doesn't make that much difference in this example, but I think when there are a large number of words per cData value and a lot of words entered in the search phrase, this methodology always works.

If I drop words off the end of my keyword table, it would look like this:
iKey	cData
----	-----
1 	mouse pez frame compaq
1	pez frame compaq
1	frame compaq
1	compaq

2	drive compaq file xml mouse
2	compaq file xml mouse
2	file xml mouse
2	xml mouse
2	mouse

3	frame mouse ring
3	mouse ring
3	mouse
User can enter "mouse AND frame" and get iKey=1 and iKey=3, same behavior as above. But if user enters "frame AND mouse"... Hey, I suppose your way of dropping off cData words will work.... Since VFP char columns are always fixed length, it would not change the size of the table itself, but maybe it would change the size of the index. I'll have to test that out.






* Side note.
Can anyone say that a SQL-Select Where cData="string%" is any slower than EXACT=OFF and SQL-Select Where cData="string" ?


>Back to your example.
>
>If you type "telephone system" into the search text field without the quotes, the default behavior is results with "telephone" and "system" anywhere. You only need to search for the exact phrase if your end user puts it in quotes.
>
>As a result, when generating your cData fields, when you take the first word off the front, I do not think you need to tack that word onto the end. Rather, if space allows, take the next word you find from that text source. If there is nothing more at the end of the text source, then you can just leave the rest blank.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform