Problem with search formula?

I am writing this string and pass it to the search method…String formula = "( (Form = " + “"”+“Person”+ “")” + “AND” + " @Begins(FirstName; "+ “"”+ “A”+ “") )”

but i m getting error…but when i use it separately it works means…String formula1 ="( (Form = " + “"”+“Person”+ “")” and String formula2 = " @Begins(FirstName; "+ “"”+ “A”+ “") )”…

both of these formula gives me right values but when i combined these two in to one…this is giving the Formula Error…

Please help me out…

thanx

Amit Saini

Subject: RE: Problem with search formula?

String formula = "( (Form = " + “"”+“Person”+ “")” + “AND” + " @Begins(FirstName; "+ “"”+ “A”+ “") )”

The problem is that “AND” is not an operator in macro language.

Why do you make things difficult for yourself with all those extra quotes?

String formula = {Form = “Person” & @Begins(FirstName; “A”)}

Subject: RE: Problem with search formula?

thanx a lot andre,but i m writing this program in java so i have to do like that only…could you please tell me whether the db.search is better or FTsearch() is better in performance…I m new to this formula language…

thanx for your reply

Amit

Subject: RE: Problem with search formula?

Java or no Java, you can do a string constant with just one set of enclosing quotes, as Bill Ernest showed.

If you have a full-text index, a full-text search is generally a lot faster for databases with many documents. If you don’t have a full-text index, a full-text search is much slower.

The capabilities of the two types of search are not identical, however. In the case of your formula, there’s no way to express it as a full-text search because you can only compare whole words of text – there’s no way to express the @Begins test you are doing in the full-text query language.

There’s a third way of searching that you may want to consider. Create a view with a selection formula that includes only the documents you’re interested in. Notes maintains this result set in the database file, so that when you go to read documents from the view, the server only has to update the view with any documents that were modified since the view was last used.

Or, in this case, it might be better to create a view with the selection formula SELECT Form = “Person” and the first sorted column displaying the field FirstName. You can use View.GetAllDocumentsByKey(“A”, False) to get all the documents whose first names begin with “A”. Ditto for any other initial letter you want to load. Besides being efficient, this has the extra advantage of allowing you to retrieve the documents in view-sorted order if you desire (though to do this while loading all matching documents, you would use a ViewEntryCollection).

Subject: Try: “((Form = "Person") & @Begins(FirstName; "A"))”