I am attempting to connect to a local notes database and spit back a result on how many of a given entry there are. No matter what I do though the result is 0. The entry is indeed in the database. One interesting thing to note is that if I do the reverse of the query the result is 259, for example !=, regardless if I use an entry that is in the database or not, for example AnActualName vs Adflsdk, both != statements return 259. I also tried case sensitivity of @UpperCase
Enumeration en = uNames.elements();
try
{
NotesThread.sinitThread();
Session s = NotesFactory.createSession();
Database db = s.getDatabase(null,"names.nsf");
System.out.println(db.getFileName());
while (en.hasMoreElements())
{
String currentName = en.nextElement().toString();
System.out.println(currentName);
String query ="ShortName = \"" + currentName + "\"";
System.out.println(query);
DocumentCollection dc = db.search(query);
System.out.println(dc.getCount());
if (dc.getCount() > 0)
{
recentNames.addElement(currentName);
}
}
Subject: Please refer to basic debugging principles 101
db.Search is giving you the right result, given its inputs. I guarantee that. You have to make sure the inputs are correct. Are you sure the item ShortName is stored in the documents (e.g. it’s not “computed for display”)? Are you sure there aren’t extra weird characters in the search string? Can you prove the result is wrong by finding one specific document that should match the search criteria, e.g. by doing a full-text search for your target value? Look at that document’s properties dialog from a view. What’s the value of its ShortName field?
Don’t assume – check.
Incidentally, this is a poor-performing way to get documents from a database. Instead, use a keyed search in a view that’s sorted by the value you want to search for.
Subject: yes
Thanks for the reply. Yes, I have verified that the value exists in the database. Yes, I have made sure that there are no special characters. Yes, I have made sure that “ShortName” does contain the value I am looking for. (I copied the value exactly as it is displayed). I honestly cannot see any reason why the query would come back with the result of zero.
Debugging reveals the exact value of query to be
ShortName = “PLYMIRR”
which returns
0
When I have verified that the value does indeed exist.
Subject: Create a view with the same selection formula.
Does it find a document?
Did you try the full-text search?
I’m sorry if I seem to be stating the obvious, but I have no way to know to what extent you know what you’re doing.
The statement “I have verified that the value exists in the database.” is vague. How did you do this verification? If your answer involves opening a document, you did it wrong.
Subject: *is the db full text indexed? try FTSearch
Subject: Can’t do FT
I can do FT on the one I am using for testing purposes, but the application that I am developing will be distributed and not all of them will be indexed. Any other ideas?