You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by lamino <ya...@yahoo.fr> on 2008/11/08 05:41:19 UTC
Strange behaviour of FrenchAnalyzer when using accents
Greetings,
I'm getting a strange behaviour when using the FrenchAnalyzer.
Calling the same class (Searcher.java, see below) from a JSP file and from a
Java class, gives differents results when the query contains accents !
Notice the different value of the query object :
q = "secrétaire"
If calling from main.jsp query = text:secrétair
If calling from main.java query = text:secretair
Source code (Search.java, Main.jsp, Main.java) :
public void search() {
String q = "secrétaire";
String indexDirectory = "c:\\temp\\accent\\index2";
try {
IndexSearcher searcher = new IndexSearcher(indexDirectory);
QueryParser parser = new QueryParser("text", new
FrenchAnalyzer());
Query query = parser.parse(q);
Hits hits = searcher.search(query);
System.out.println(query);
System.out.println("Results for '" + q + "': " +
hits.length());
Iterator iter = hits.iterator();
while (iter.hasNext()) {
Hit hit = (Hit) iter.next();
Document doc = hit.getDocument();
}
} catch (Exception e) {
}
}
=====================Main.jsp=====================
<%
Search s = new Search();
s.search();
%>
OUPUT :
text:secrétair
Results for 'secrétaire': 0
=====================Main.java=====================
public class Main {
public static void main(String[] args) {
Search s = new Search();
s.search();
}
}
OUTPUT :
text:secretair
Results for 'secrétaire': 1
I will appreciate your help, thank you in advance.
Lamine
--
View this message in context: http://www.nabble.com/Strange-behaviour-of-FrenchAnalyzer-when-using-accents-tp20392978p20392978.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Strange behaviour of FrenchAnalyzer when using accents
Posted by lamino <ya...@yahoo.fr>.
No it doesn't, still gettig the same output... :-(
Daniel Naber-10 wrote:
>
> On Samstag, 8. November 2008, lamino wrote:
>
>> String q = "secrétaire";
>
> Does it help if you escape it like this: "secr\u00e9taire"? The java
> compiler might interpret non-ASCII chars differently, depending on the
> environment it runs in.
>
> Regards
> Daniel
>
> --
> http://www.danielnaber.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Strange-behaviour-of-FrenchAnalyzer-when-using-accents-tp20392978p20397820.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Strange behaviour of FrenchAnalyzer when using accents
Posted by Daniel Naber <lu...@danielnaber.de>.
On Samstag, 8. November 2008, lamino wrote:
> String q = "secrétaire";
Does it help if you escape it like this: "secr\u00e9taire"? The java
compiler might interpret non-ASCII chars differently, depending on the
environment it runs in.
Regards
Daniel
--
http://www.danielnaber.de
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org