lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laura Hollink <lau...@cs.vu.nl>
Subject no results for query with special characters
Date Mon, 27 Apr 2009 11:32:01 GMT
Hi,

I have built an index using the standardAnalyser, and am now querying  
that index, also with standardAnalyser. However, I get results I don't  
understand.

I know there are a few documents about Brazil in my corpus. My corpus  
is in Dutch, and the Dutch term used is "Brazilië".

I query the index in three ways for the string "Brazilië"
1) by entering a query in the command line
2) by hardcoding the query in my java code
3) by reading in a query file, with one query in it.

The first two give me documents back, but the latter doesn't.

###CODE SNIPPET####

QueryParser parser = new QueryParser("skos:prefLabel",new  
StandardAnalyzer());//the field that I need is called skos:prefLabel.
Directory fsDir = FSDirectory.getDirectory(indexDir, false);
IndexSearcher is = new IndexSearcher(fsDir);

//1) Query is command line argument
Query query = parser.parse(queryarg);
System.out.println(query.toString());
Hits hits = is.search(query);
System.out.println(hits.length());

//2) Query is hardcoded
query = parser.parse("Brazilië");
System.out.println(query.toString());
hits = is.search(query);
System.out.println(hits.length());

//3) Query is in separate queryfile called testquery.txt
query = parser.parse(queries[0]); //queries is a String[] in which I  
read all (in this case only one) queries from the file testquery.txt
System.out.println(query.toString());
hits = is.search(query);
System.out.println(hits.length());

#################


Now when I execute my code with:
java MyQueryPoser2 Brazilië

I get:
skos:prefLabel:brazili?
4
skos:prefLabel:brazili?
4
skos:prefLabel:brazili
0

The parsed queries are different and the resultlists are different for  
the three methods. Why doesn't the query from file give my any results?

I am working on a mac. Could this be due to some special file encoding?

The queryfile does contain the right string:
lauras-macbook-pro:MetLucene laura$ cat testquery.txt
Brazilië


thanks for any help.

Laura


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message