2

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!

Vincent
  • 31
  • 4
  • "[name]=Vincent" works perfect for me. That shouldn't be the issue. Did you print() the queryStr just to be sure URL params are working correct? – Knut Herrmann May 22 '14 at 15:11
  • Is this part of the reason? " you can't test whether the value is exactly equal to the search string, only whether it contains the search string (even if you use the = operator)". See http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Searching_for_Documents#Full-text+Search – Per Henrik Lausten May 22 '14 at 19:28

3 Answers3

4

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/

David Leedy
  • 3,583
  • 18
  • 38
  • Thanks for answer it. Is it that contains/CONTAINS/= work the same way? I already tried it, and something like field name="\*Vincent*",but the search result is not correct either. I will study the blog you gave me,thanks. – Vincent May 22 '14 at 15:03
  • You might need to prepend it with the word "FIELD" as in "field myField1 contains mySearch1 . Another thing to try is to go into the Notes Client and perform your search there. There is a advanced section with different builders that can help get you the syntax – David Leedy May 22 '14 at 15:09
  • thanks, I tried FIELD,still failed. The most weird thing is that it worked well on the notes client.At the begining ,i thought maybe there is something different between client and web. I'm not sure. There must be something I ignored. Another thing is ,if i set the search property of the view panel by using a static value like above. the browser return 500 internal error. is it should be the same as i use SSJS. I don't know the difference,can you tell me. And I'was using my designer to preview the local database. I didn't put it on the server. Would it cause this problem. – Vincent May 22 '14 at 15:31
  • It is not the syntax of search string what causes the issue. It is something in your test environment. It is always better to test against a server even it is a server on your machine. – Knut Herrmann May 22 '14 at 15:37
1

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.

Vincent
  • 31
  • 4
0

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).

Community
  • 1
  • 1
Simon O'Doherty
  • 9,259
  • 3
  • 26
  • 54
  • Thanks for answering. you teach me lots of things. I will test them next week. – Vincent May 23 '14 at 13:07
  • Another Interesting thing is, when i deleted the cache of the client. I can use static value for the search property of the view panel. Before that it generated a " query is not understandable" error. @KnutHerrmann – Vincent May 23 '14 at 13:13
  • The FTI debug might show you how the search term is being corrupted. – Simon O'Doherty May 24 '14 at 05:50