0

i try to make a search function in ssjs that looks like this.

notesdocumentcollection.ftsearch('"*' + searchword + '*"');

i have a document with this field value "Dr. Max Muster". if i search for "dr" i get a result. if i search for "dr. max" i don't get a result. if i remove the wildcard and type "dr. max" i will get an result.

i also tryed it like this

notesdocumentcollection.ftsearch('*' + searchword + '*');

Is there any way to get an result with wildcards and special characters in the search query ?

P.S. If i try this in the notesclient in the view it will work.

EDIT: for this query "dr. ma" i got this debug results from the server

IN FTGSearch option = 0x400089 
[12CC:000A-1A30] Query: dr. ma 
[12CC:000A-1A30] Engine Query: ("drma") 
[12CC:000A-1A30] OUT FTGSearch error = F22 
[12CC:000A-1A30] FTGSearch: found=0, returne 
[12CC:000A-1A30] IN FTGSearch option = 0x40008C 
[12CC:000A-1A30] Query: *"dr**ma"* 
[12CC:000A-1A30] Engine Query: ("*dr**ma*") 
[12CC:000A-1A30] OUT FTGSearch error = F22 
[12CC:000A-1A30] FTGSearch: found=0, returned=0, start=0, count=0, limit=0
Pudelduscher
  • 359
  • 3
  • 18
  • is 'ft index' updated, right? maybe try to re-create it. but from what - see , you search request is correct. – Dmytro Pastovenskyi Oct 11 '12 at 08:02
  • no, every thing is updated. As i say, i've tryed it in the notesclient and every thing works. – Pudelduscher Oct 11 '12 at 08:17
  • I believe the basic issue here is that FTSearch is word-oriented. I.e., the indexer creates an index of the words that occur in each document, and to do that it needs to have a definition of what a "word" is. In most languages, a word is defined as a set of consecutive characters with no spaces and no punctuation marks. I.e., "Dr" is a word. "Dr." is not a word, because the "." is a punctuation character and it is not included in the index, therefore you can't really search for it. – Richard Schwartz Oct 11 '12 at 23:55
  • But it appears that if you enter "Dr." in a normal query, the query parser is smart enough to see that you are searching for "Dr." and it changes it to "Dr". "Dr" is a word in the index, so your search succeeds. However, if you put a wildcard into the query, it looks like the query parser is not smart enough to do that. I'm not sure why that would be the case -- maybe a bug, or maybe a known limit... I don't know. – Richard Schwartz Oct 12 '12 at 00:02
  • Thanks, i also think that it is an bug or a limit. – Pudelduscher Oct 12 '12 at 06:03

3 Answers3

1

OK first up the search engine uses a trigram system. So searching for 2 characters will not work as expected. The wild cards may be helping but there is no guarantee it will get everything.

So as I understand the next part if you manually type in the following into the Full Text Search bar in the notes client and it works? (quotes included)

"*dr. max*"

One thing to be aware of in the Notes client is that you can activate two different search modes (switch in basic preferences). Web query and Notes query.

By default web query is on (IIRC), so you search as if you would your standard internet search engines.

If you have switched it to Notes query, or the search starts with an all capitals word it use the syntax that Notes has used previously.

So it possible you are are seeing differences in the client vs XPages due to that.

To test this you can debug as follows. On the Domino server console type the following.

set config DEBUG_THREADID=1
set config CONSOLE_LOG_ENABLED=1
set config Debug_FTV_Search=1

Now do a search in the notes client and the XPage. It will generate something like the following on the Domino Console (note: I added the numbers at the start for the important lines).

IN FTGSearch
[07FC:0048-0A94] option = 0x400219
1. [07FC:0048-0A94] Query: ("*test*")
2. [07FC:0048-0A94] Engine Query: ("*test*"%STEM)
3. [07FC:0048-0A94] GTR query performed in 6 ms. 5 documents found
4. [07FC:0048-0A94] 0 documents disualified by deletion
5. [07FC:0048-0A94] 0 documents disqualified by ACL
6. [07FC:0048-0A94] 0 documents disqualified by IDTable
7. [07FC:0048-0A94] 0 documents disqualified by NIF
8. [07FC:0048-0A94] Results marshalled in 3 ms. 5 documents left
9. [07FC:0048-0A94]  OUT FTGSearch error = 0
[07FC:0048-0A94] FTGSearch: found=5, returned=5, start=0, count=0, limit=0
[07FC:0048-0A94] Total search time 10 ms.

Explanation of each bit.

  1. String you sent to the search engine. In this case it was "test" (with quotes)
  2. The compiled search string.
  3. How long it took and total number of documents found.
  4. Total discarded because it was flagged as deleted.
  5. Total discarded because you did not have the rights to view them.
  6. Total discarded because of the IDTable results.
  7. Total discarded because they would not appear in the view you are searching from.
  8. Time it took and remaining documents.
  9. If any errors occurred.

So generate those two search results and post them if it is not obvious why it mentioned it didn't work.

Simon O'Doherty
  • 9,259
  • 3
  • 26
  • 54
  • yes it works in the notes client with the quotes included, if i search directly in a view. I will try the debung options and let you now what happend. – Pudelduscher Oct 11 '12 at 10:01
  • for this query "dr. ma" i got this result `IN FTGSearch option = 0x400089 [12CC:000A-1A30] Query: dr. ma [12CC:000A-1A30] Engine Query: ("drma") [12CC:000A-1A30] OUT FTGSearch error = F22 [12CC:000A-1A30] FTGSearch: found=0, returne [12CC:000A-1A30] IN FTGSearch option = 0x40008C [12CC:000A-1A30] Query: *"dr**ma"* [12CC:000A-1A30] Engine Query: ("*dr**ma*") [12CC:000A-1A30] OUT FTGSearch error = F22 [12CC:000A-1A30] FTGSearch: found=0, returned=0, start=0, count=0, limit=0` – Pudelduscher Oct 11 '12 at 10:28
  • So . in a notes query can't be searched on if it isn't in quotes. There are a number of others (but I can never find the technote as the characters can't be searched on. :). Your second query of \*"dr**ma"\* is an invalid search. I don't think you can use wild cards in that fashion (beside quoted text), I must check. Also ** would be treated as a literal inside the quotes. – Simon O'Doherty Oct 11 '12 at 14:22
  • Might help if you add that report output to your main post, in case stackoverflow is stripping stuff. – Simon O'Doherty Oct 11 '12 at 14:24
  • This log is from 1 search. I only search for "dr. ma". I don't know where the server get's the query for ("*dr**ma*") – Pudelduscher Oct 12 '12 at 05:58
  • you can see "dr. ma" (without quotes) was turned into "drma". I know the full stop would be dropped, but it should have looked for "dr ma" (without quotes). – Simon O'Doherty Oct 12 '12 at 08:15
0

The documentation for FTSearch says to enclose words and phrases in quotes. So try this (where you enclose the searchword variable in quotes - and not the wildcard star):

notesdocumentcollection.ftsearch('*"' + searchword + '"*');
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
0

the Notes Fulltext Query Syntax is a better kept secret than the Disney Time share apartments (if you ever were at Disney you get the drift).

The official syntax guide is here: http://www-10.lotus.com/ldd/dominowiki.nsf/dx/full-text-syntax

What helped me a lot is to take the searchsite.ntf and rip it apart. Inside all concepts of FTSearch have been implemented in a working fashion (code that works beats documentation any time).

Hope that helps

stwissel
  • 20,110
  • 6
  • 54
  • 101
  • Unfortunately not. I think my search query is correct, because it works in the notes client. The question is why it does not work in ssjs. – Pudelduscher Oct 11 '12 at 10:03
  • Works in the Notes client as in: "LotusScript code" or "typed into the search bar". In the later case my advice still stands: RIP the searchsite.ntf apart. It has all the finer details – stwissel Oct 11 '12 at 18:58