Vincent
Vincent

Reputation: 31

FTsearch did not work correct in xpage's view control

I have a view control and make the query string by the search param from the application layout control.Full text index is already enabled, the code in the search property like below:

var queryStr="";
if(param.option=="byName"){
queryStr="[name]="+param.search;
}
else{
queryStr="[title]="+param.search;
}
return queryStr;

i found that the queryStr can be made correct,like "[name]=Vincent",but the view shows all documents contain the word "Vincent",not only the spesific field "name". Just like I used "Vincent" for search.

I want to know how to get the correct result.thank you!

Upvotes: 2

Views: 1429

Answers (3)

Vincent
Vincent

Reputation: 31

Finally I find the problem. The full-text syntax works fine, both "field/FIELD/[]" or "contains/CONTAINS/=" can work. But I used an application layout for search. The search button generate two parameters: "option"(if you choosed before) and "search" by default. The search parameter is used as the value of the view control's search property directly. When I customed this property by myself ,it would not be used(if the ssjs return a null) or generate an " not understandable" error(if the ssjs return a string,which is normal in most situation). The solution is give that two parameters custom parameter name .like fieldName for option, searchText for search. After that, you can use param.fieldName and param.searchText to build your full-text search string.I have tried ,and it works fine now.

Upvotes: 1

Simon O'Doherty
Simon O'Doherty

Reputation: 9359

For the most part David Leedys answer should work. Some pointers on diagnosing FTI issues though.

1. Your search phrase must be surrounded by quotes. Example:

queryStr='[name] = "' + param.search + '"';

2. Get the actual fully constructed search string and test it in the Notes FTI search bar. Do you get the same incorrect results? If so, then fix the search string.

3. If it is working in the Notes client then add the following debug to the Domino servers notes.ini file (alternatively: set config from console).

Debug_FTV_Search=1

When you run a search it should generate debug like this: Search [name] CONTAINS "String"

IN FTGSearch
[22E8:008A-1710] option = 0x400219
[22E8:008A-1710] Query: ( FIELD name CONTAINS  "String")
[22E8:008A-1710] Engine Query: ("String"%STEM@F134)
[22E8:008A-1710] GTR query performed in 10 ms. 2 documents found
[22E8:008A-1710] 0 documents disualified by deletion
[22E8:008A-1710] 0 documents disqualified by ACL
[22E8:008A-1710] 0 documents disqualified by IDTable
[22E8:008A-1710] 0 documents disqualified by NIF
[22E8:008A-1710] Results marshalled in 8 ms. 2 documents left
[22E8:008A-1710]  OUT FTGSearch error = 0
[22E8:008A-1710] FTGSearch: found=2, returned=2, start=0, count=0, limit=0
[22E8:008A-1710] Total search time 22 ms.

You want to check the Query and Engine Query from client search vs XPage to see what is generated. If they don't match, update your question with the results so we can see what's going on.

The disqualified section tells you if search results were dropped. For example, if your XPage was running under credentials that were not allowed to view the documents, then disqualified by ACL would have a value.

4. The Notes client has two search syntax methods. There is "Notes" and "Web" style. By default for R9 (and R8.x IIRC) is Web style (client). The server uses Notes style.

You can change the client behavior in the Basic Settings preferences.

Search settings

The Web style does not understand Notes syntax unless the first word in the search is a reserved keyword and all in uppercase.

Example.

  • Will use "web" search: field name contains "string"
  • Will use "Notes" search: FIELD name contains "string"

I am not sure if that impacts XPiNC though (never tested it).

Upvotes: 0

David Leedy
David Leedy

Reputation: 3593

Should it be? "[name] CONTAINS "+param.search;

similar to this: [Projectname] CONTAINS top secret

Use the word CONTAINS rather then = ?

I'm not 100% sure but there was a recent blog post on seaching just the other day: http://lostinxpages.com/2014/05/15/exporting-to-excel-using-queries-in-xpages/

Upvotes: 4

Related Questions