lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: no results for query with special characters
Date Mon, 27 Apr 2009 13:24:45 GMT
Hi


The problem may well lie with the reading of the queries from disk
into your program.
Using an InputStreamReader with correct encoding (UTF-8?) should solve it.


--
Ian.


On Mon, Apr 27, 2009 at 12:32 PM, Laura Hollink <laurah@cs.vu.nl> wrote:
> 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
>
>

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