// Query query = QueryParser.parse(searchString, ParsedObject.FIELDNAME_CONTENT, analyzer);
}
catch (ParseException e)
{
List<ParsedObject> resultList = new ArrayList<ParsedObject>();
SearchResults results = new SearchResultsImpl(resultList);
return results;
}
try
{
hits = searcher.search(query);
}
catch (IOException e)
{
List<ParsedObject> resultList = new ArrayList<ParsedObject>();
SearchResults results = new SearchResultsImpl(resultList);
return results;
}
int hitNum = hits.length();
List<ParsedObject> resultList = new ArrayList<ParsedObject>(hitNum);
for(int i=0; i<hitNum; i++)
{
ParsedObject result = new BaseParsedObject();
try
{
Document doc = hits.doc(i);
addFieldsToParsedObject(doc, result);
result.setScore(hits.score(i));
Field type = doc.getField(ParsedObject.FIELDNAME_TYPE);
if(type != null)
{
result.setType(type.stringValue());
}
Field key = doc.getField(ParsedObject.FIELDNAME_KEY);
if(key != null)
{
result.setKey(key.stringValue());
}
Field description = doc.getField(ParsedObject.FIELDNAME_DESCRIPTION);
if(description != null)
{
result.setDescription(description.stringValue());
}
Field title = doc.getField(ParsedObject.FIELDNAME_TITLE);
if(title != null)
{
result.setTitle(title.stringValue());
}
Field content = doc.getField(ParsedObject.FIELDNAME_CONTENT);
if(content != null)
{
result.setContent(content.stringValue());
}
Field language = doc.getField(ParsedObject.FIELDNAME_LANGUAGE);
if (language != null)
{
result.setLanguage(language.stringValue());
}
Field classname = doc.getField(ParsedObject.FIELDNAME_CLASSNAME);
if (classname != null)
{
result.setClassName(classname.stringValue());
}
Field url = doc.getField(ParsedObject.FIELDNAME_URL);
if (url != null)
{
result.setURL(new URL(url.stringValue()));
}
Field[] keywords = doc.getFields(ParsedObject.FIELDNAME_KEYWORDS);
if(keywords != null)
{
String[] keywordArray = new String[keywords.length];
for(int j=0; j<keywords.length; j++)
{
Field keyword = keywords[j];
keywordArray[j] = keyword.stringValue();
}
result.setKeywords(keywordArray);
}
resultList.add(i, result);
}
catch(IOException e)
{
//logger
}
}
if (searcher != null)
{
try
{
searcher.close();
}
catch (IOException ioe)
{
//logger.error("Closing Searcher", ioe);
}
}
SearchResults results = new SearchResultsImpl(resultList);
return results;
}