Skip to content

Commit

Permalink
fix: Fixed category not using queryparser (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikcio committed Oct 24, 2022
1 parent 9a26cec commit 2623b18
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Examine.Lucene/Search/LuceneSearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private ISearchResults Search(QueryOptions options)
query = new BooleanQuery
{
// prefix the category field query as a must
{ GetFieldInternalQuery(ExamineFieldNames.CategoryFieldName, new ExamineValue(Examineness.Explicit, Category), false), Occur.MUST }
{ GetFieldInternalQuery(ExamineFieldNames.CategoryFieldName, new ExamineValue(Examineness.Explicit, Category), true), Occur.MUST }
};

// add the ones that we're already existing
Expand Down
31 changes: 31 additions & 0 deletions src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,37 @@ public void NativeQuery_Single_Word()
}
}

[Test]
public void Uppercase_Category()
{
var analyzer = new StandardAnalyzer(LuceneInfo.CurrentVersion);
using (var luceneDir = new RandomIdRAMDirectory())
using (var indexer = GetTestIndex(
luceneDir,
analyzer,
new FieldDefinitionCollection(new FieldDefinition("parentID", FieldDefinitionTypes.Integer))))
{
indexer.IndexItems(new[] {
ValueSet.FromObject(1.ToString(), "cOntent",
new { nodeName = "location 1", bodyText = "Zanzibar is in Africa"}),
ValueSet.FromObject(2.ToString(), "cOntent",
new { nodeName = "location 2", bodyText = "In Canada there is a town called Sydney in Nova Scotia"}),
ValueSet.FromObject(3.ToString(), "cOntent",
new { nodeName = "location 3", bodyText = "Sydney is the capital of NSW in Australia"})
});

var searcher = indexer.Searcher;

var query = searcher.CreateQuery("cOntent").All();

Console.WriteLine(query);

var results = query.Execute();

Assert.AreEqual(3, results.TotalItemCount);
}
}

[Test]
public void NativeQuery_Phrase()
{
Expand Down

0 comments on commit 2623b18

Please sign in to comment.