fixed bug in LuceneSearcher where it would generate a bad sql query

This commit is contained in:
tmont 2011-02-28 22:30:03 +00:00
parent 1991afa021
commit 26352fb745
5 changed files with 45 additions and 42 deletions

Binary file not shown.

View File

@ -4,37 +4,12 @@
<name>Portoa.Lucene</name> <name>Portoa.Lucene</name>
</assembly> </assembly>
<members> <members>
<member name="T:Portoa.Lucene.ILuceneDocumentHandler`1">
<summary>
Handles interaction between objects and Lucene documents
</summary>
<typeparam name="T"></typeparam>
</member>
<member name="M:Portoa.Lucene.ILuceneDocumentHandler`1.BuildDocument(`0)">
<summary>
Builds a <see cref="T:Lucene.Net.Documents.Document"/> out of another object
</summary>
<param name="source">The object from which to build the document</param>
</member>
<member name="M:Portoa.Lucene.ILuceneDocumentHandler`1.GetIdTerm(`0)">
<summary>
Gets a term representing the identifying <see cref="T:Lucene.Net.Documents.Field"/> in a
<see cref="T:Lucene.Net.Documents.Document"/>. This <see cref="T:Lucene.Net.Index.Term"/> can be used as a means
to delete documents using an <see cref="T:Lucene.Net.Index.IndexWriter"/>, for example.
</summary>
<param name="source">The object from which to create the term</param>
</member>
<member name="T:Portoa.Lucene.LuceneEntitySearcher`1">
<summary>
<see cref="T:Portoa.Search.ISearcher`1"/> implementation for entities based on <c>Lucene.NET</c>
</summary>
</member>
<member name="T:Portoa.Lucene.LuceneSearcher`1"> <member name="T:Portoa.Lucene.LuceneSearcher`1">
<summary> <summary>
<see cref="T:Portoa.Search.ISearcher`1"/> implementation based on <c>Lucene.NET</c> <see cref="T:Portoa.Search.ISearcher`1"/> implementation based on <c>Lucene.NET</c>
</summary> </summary>
</member> </member>
<member name="M:Portoa.Lucene.LuceneSearcher`1.TransformResults(System.Collections.Generic.IEnumerable{Lucene.Net.Search.ScoreDoc},Lucene.Net.Search.IndexSearcher)"> <member name="M:Portoa.Lucene.LuceneSearcher`1.TransformResults(Lucene.Net.Search.ScoreDoc[],Lucene.Net.Search.IndexSearcher)">
<summary> <summary>
Transforms the results of a search into a proper result set Transforms the results of a search into a proper result set
</summary> </summary>
@ -57,11 +32,10 @@
Gets the index directory associated with this searcher Gets the index directory associated with this searcher
</summary> </summary>
</member> </member>
<member name="T:Portoa.Lucene.LuceneEntityIndexBuilder`1"> <member name="T:Portoa.Lucene.LuceneEntitySearcher`1">
<summary> <summary>
<see cref="T:Portoa.Search.ISearchIndexBuilder`1"/> implementation for entities based on <c>Lucene.NET</c> <see cref="T:Portoa.Search.ISearcher`1"/> implementation for entities based on <c>Lucene.NET</c>
</summary> </summary>
<typeparam name="T">The entity to build the index for</typeparam>
</member> </member>
<member name="T:Portoa.Lucene.LuceneIndexBuilder`1"> <member name="T:Portoa.Lucene.LuceneIndexBuilder`1">
<summary> <summary>
@ -99,5 +73,31 @@
Application logger Application logger
</summary> </summary>
</member> </member>
<member name="T:Portoa.Lucene.LuceneEntityIndexBuilder`1">
<summary>
<see cref="T:Portoa.Search.ISearchIndexBuilder`1"/> implementation for entities based on <c>Lucene.NET</c>
</summary>
<typeparam name="T">The entity to build the index for</typeparam>
</member>
<member name="T:Portoa.Lucene.ILuceneDocumentHandler`1">
<summary>
Handles interaction between objects and Lucene documents
</summary>
<typeparam name="T"></typeparam>
</member>
<member name="M:Portoa.Lucene.ILuceneDocumentHandler`1.BuildDocument(`0)">
<summary>
Builds a <see cref="T:Lucene.Net.Documents.Document"/> out of another object
</summary>
<param name="source">The object from which to build the document</param>
</member>
<member name="M:Portoa.Lucene.ILuceneDocumentHandler`1.GetIdTerm(`0)">
<summary>
Gets a term representing the identifying <see cref="T:Lucene.Net.Documents.Field"/> in a
<see cref="T:Lucene.Net.Documents.Document"/>. This <see cref="T:Lucene.Net.Index.Term"/> can be used as a means
to delete documents using an <see cref="T:Lucene.Net.Index.IndexWriter"/>, for example.
</summary>
<param name="source">The object from which to create the term</param>
</member>
</members> </members>
</doc> </doc>

View File

@ -20,6 +20,7 @@ using Directory = Lucene.Net.Store.Directory;
using Version = Lucene.Net.Util.Version; using Version = Lucene.Net.Util.Version;
namespace VideoGameQuotes.Web.Configuration { namespace VideoGameQuotes.Web.Configuration {
public class EnableSearchWithLucene : UnityContainerExtension { public class EnableSearchWithLucene : UnityContainerExtension {
protected override void Initialize() { protected override void Initialize() {
var indexWriterLifetimeManager = new ExplicitlyDisposableLifetimeManager<IndexWriter>( var indexWriterLifetimeManager = new ExplicitlyDisposableLifetimeManager<IndexWriter>(
@ -56,12 +57,7 @@ namespace VideoGameQuotes.Web.Configuration {
} }
private static IndexWriter CreateIndexWriter(IUnityContainer container) { private static IndexWriter CreateIndexWriter(IUnityContainer container) {
return new IndexWriter( return new IndexWriter(container.Resolve<Directory>(), container.Resolve<Analyzer>(), true, IndexWriter.MaxFieldLength.UNLIMITED);
container.Resolve<Directory>(),
new StandardAnalyzer(Version.LUCENE_29),
true,
IndexWriter.MaxFieldLength.UNLIMITED
);
} }
#endregion #endregion

View File

@ -33,7 +33,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Lucene.Net, Version=2.9.2.2, Culture=neutral, processorArchitecture=MSIL" /> <Reference Include="Lucene.Net">
<HintPath>..\..\Lib\Lucene.Net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Practices.Unity"> <Reference Include="Microsoft.Practices.Unity">
<HintPath>..\..\Lib\Microsoft.Practices.Unity.dll</HintPath> <HintPath>..\..\Lib\Microsoft.Practices.Unity.dll</HintPath>
@ -49,7 +51,9 @@
<Reference Include="Portoa.Log4Net"> <Reference Include="Portoa.Log4Net">
<HintPath>..\..\Lib\Portoa.Log4Net.dll</HintPath> <HintPath>..\..\Lib\Portoa.Log4Net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Portoa.Lucene, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" /> <Reference Include="Portoa.Lucene">
<HintPath>..\..\Lib\Portoa.Lucene.dll</HintPath>
</Reference>
<Reference Include="Portoa.NHibernate, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Portoa.NHibernate, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lib\Portoa.NHibernate.dll</HintPath> <HintPath>..\..\Lib\Portoa.NHibernate.dll</HintPath>
@ -208,9 +212,7 @@
<Content Include="Views\Shared\Site.Master" /> <Content Include="Views\Shared\Site.Master" />
<Content Include="Views\Web.config" /> <Content Include="Views\Web.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="App_Data\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\VideoGameQuotes.Api\VideoGameQuotes.Api.csproj"> <ProjectReference Include="..\VideoGameQuotes.Api\VideoGameQuotes.Api.csproj">
<Project>{329FAB1F-A18D-4B7B-9E3C-A0C157E55503}</Project> <Project>{329FAB1F-A18D-4B7B-9E3C-A0C157E55503}</Project>

View File

@ -7,8 +7,13 @@
</p> </p>
<% <%
if (Model.Results.Any()) {
foreach (var result in Model.Results) { foreach (var result in Model.Results) {
Html.RenderPartial("SingleQuote", new QuoteModel { Quote = result.Record, User = Model.User }); Html.RenderPartial("SingleQuote", new QuoteModel { Quote = result.Record, User = Model.User });
} }
%> } else { %>
<p>
Nothing turned up. You suck at searching for things and you&rsquo;re ugly.
</p>
<% } %>
</asp:Content> </asp:Content>