Home » Server Options » Text & interMedia » How to retrieve values of the attributes
How to retrieve values of the attributes [message #248673] Sat, 30 June 2007 04:39
zizo-mizo
Messages: 1
Registered: June 2007
Junior Member
Hello all,
I have a problem with ultra search that I cannot retrive the value of custom attribute.

I'm using Oracle database 10g release 10.2.0.1.0 and I try to use Oracle Ultra Search to perform a full text search on this database tables.
The operating system used is Windows XP professional, and I'm using a JDBC connection for testing.
I made a custom search attribute and map this attribute with a database table column.
I made the crawling process using the Oracle Ultra Search application not by using the Oracle Ultra Search Crawler API.
When I tried to perform the full text search using the Ultra Search Query API, I found documents that match my search keywords but when I tried to retrieve the value of the custom attribute it always returns null.
I think the problem is in the mapping between the attributes and the columns.

This is a snapshot of the code used to perform the search:

public void performSearch(String databaseURL, String userName, String password, String instanceName, String keyword)
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection conn = DriverManager.getConnection(databaseURL,userName, password);

Instance instance = new Instance();
instance.setConnection(conn);
instance.setCloseConnection(false);
instance.setInstanceName(instanceName);

Collection attributes = instance.getMetaData().getAttributes();
Attribute attribute[] = (Attribute[])attributes.toArray(new Attribute[attributes.size()]);

Request req = new Request();
req.setStartIndex(0);
req.setDocsRequested(1000);
req.setAttributesFetched(attribute);

Query query = new Contains(keyword, instance.getMetaData());
req.setQuery(query);

Result result = instance.getResult(req);
Iterator searchResult = result.iterator();

int i = 0;
while(searchResult.hasNext())
{
Document doc = (Document)searchResult.next();
Iterator iter = doc.getAvailableAttributes().iterator();
while(iter.hasNext())
{
Attribute attr = (Attribute)iter.next();

System.out.print(attr.getName() + ": ");
System.out.println(doc.getAttribute(attr));

Iterator values = doc.getAttributeValues(attr).iterator();

while(values.hasNext())
{
System.out.println("Atrribute Values: " + values.next());
}

}
i++;
}
System.out.println("No of Documents is: " + i);
}
catch (Exception e)
{
e.printStackTrace();
}
}

Thanks in advance for your help.
Previous Topic: Spell Check in iStore Product Search
Next Topic: How do I get Oracle Text to index files on a file server?
Goto Forum:
  


Current Time: Thu Mar 28 07:28:19 CDT 2024