My requirement is to collect the Lotus Notes documents which, for a given set of search terms, contain either:
- all of these terms,
- any of these terms
- or none of these terms.
I am using the Database.FTsearch(...) method by generating a query for the particular phrase and passing the query to that method. I found that there is another method: Database.search(string arg1). How can I use that method for all the three of the conditions mentioned above?
The NotesDatabase search method takes a formula string as its first parameter. You can pass a formula such as:
Which would match the document if any of the three words were in the body. To make it match on all words, just change the ORs (||) to ANDs (&&).
Note that this method searches through all documents without an index, and can be very slow if there thousands of documents. The FTSearch method is faster but requires you to turn full-text indexing on to work efficiently.