Closed mykhayloArtymyshyn closed 11 years ago
Which Query Parser are you using in Luke?
Luke splits MERSEDES-BENZ to 2 terms indepent on settings in QueryParser tab
The Luke QueryParser behaves differently than the Lucene.Net QueryParser as you can see in these example tests:
using Lucene.Net.Analysis.Standard;
using Lucene.Net.QueryParsers;
using NUnit.Framework;
using Version = Lucene.Net.Util.Version;
namespace Lucene.Net.Linq.Tests.Integration
{
[TestFixture]
public class QueryParserTests
{
readonly QueryParser parser = new QueryParser(Version.LUCENE_30, "Text", new StandardAnalyzer(Version.LUCENE_30));
[Test]
public void TreatsHyphenAsExactPhrase()
{
var query = parser.Parse("MERSEDES-BENZ");
Assert.That(query.ToString(), Is.EqualTo("Text:\"mersedes benz\""));
}
[Test]
public void MultiWord()
{
var query = parser.Parse("MERSEDES BENZ");
Assert.That(query.ToString(), Is.EqualTo("Text:mersedes Text:benz"));
}
}
}
This behavior is not specific to Lucene.Net.Linq. Perhaps the Lucene.Net users group can explain why it behaves differently.
Incidentally isn't the brand spelled Mercedes-Benz (with a "c", not an "s")?
I'm not sure that is lucene.net behaviour. In the ReflectionFieldMapper.CreateQuery method(ln 142) I got mercedes-benz as pattern parameter instead of mercedes-benz (The same for \ instead of \ or ( instead of (). So in this method I use pattern.Replace("\", string.Empty) instead of pattern, and it start to work as I need. Thanks.
when do search by MERSEDES-BENZ, lucene.net.linq builds query {text:mersedes-benz} and has no results, lucene luke builds {text:mersedes text:benz} and find all items