This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Parse the givven query string to a Lucene Query object | |
/// </summary> | |
/// <param name="searchQuery">The query string</param> | |
/// <param name="parser">The Lucense QueryParser</param> | |
/// <returns>A Lucene Query object</returns> | |
private Query ParseQuery(string searchQuery, QueryParser parser) | |
{ | |
parser.AllowLeadingWildcard = true; | |
Query q; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
namespace LuceneWrapper.TestApp | |
{ | |
public class PersonDocument : ADocument | |
{ | |
private string lastName; | |
private string firstName; | |
private IEnumerable<string> languages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace LuceneWrapper | |
{ | |
/// <summary> | |
/// Class to represent the Searh results | |
/// </summary> | |
public class SearchResult | |
{ | |
public string SearchTerm { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected SearchResult Search<T>(string field, string searchQuery) where T : IDocument | |
{ | |
Log.DebugFormat("Searching for Type: {0} with query \"{1}\" for field \"{2}\"", typeof(T), searchQuery, field); | |
//Fetch the possible fields to search on | |
PropertyInfo[] properties = typeof(T).GetProperties(); | |
var fields = new List<string>(); | |
var fieldsToSearchOn = new List<string>(); | |
foreach (PropertyInfo property in properties) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var searcher = new IndexSearcher(LuceneDirectory)) | |
{ | |
Log.Debug("Starting new IndexSearcher"); | |
var analyzer = new StandardAnalyzer(Version.LUCENE_30); | |
var searchResults = new SearchResult | |
{ | |
SearchTerm = searchQuery, | |
SearchResultItems = new List<SearchResultItem>() | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using log4net; | |
using Lucene.Net.Analysis.Standard; | |
using Lucene.Net.Index; | |
using Lucene.Net.Search; | |
using Lucene.Net.Util; | |
namespace LuceneWrapper | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using Lucene.Net.Store; | |
namespace LuceneWrapper | |
{ | |
/// <summary> | |
/// The abstract base class to be implemented by everything that uses the Lucene directory | |
/// </summary> | |
public abstract class BaseSearch | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Custom attribute to define the field that can be seached on | |
/// </summary> | |
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property)] | |
public class SearchField : System.Attribute | |
{ | |
public string[] CombinedSearchFields; | |
public SearchField(params string[] values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using Lucene.Net.Documents; | |
namespace LuceneWrapper | |
{ | |
/// <summary> | |
/// Abstract class as base for all Seach Documents | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Feature Id="ProductFeature" Title="DemoWebsite.Setup" Level="1"> | |
<ComponentGroupRef Id="MyWebWebComponents" /> | |
<ComponentGroupRef Id="DemoWebsiteIssConfiguration" /> | |
<Component Directory="INSTALLFOLDER" Id="InstallFolderCmp" Guid="{88D22DB9-656B-4423-AA6A-92875F5F74EC}"> | |
<File Id="WebConfigFile" KeyPath="yes" Source="$(var.publishDir)\Web.config" Vital="yes" /> | |
</Component> | |
</Feature> |