Skip to content

Instantly share code, notes, and snippets.

View BartDM's full-sized avatar

Bart De Meyer BartDM

View GitHub Profile
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)
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
{
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
{
/// <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)
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>
<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>
<Target Name="WIX">
<!-- At last create an installer -->
<Exec
Command='"$(WixPath)candle" -ext WixIISExtension -ext WixUtilExtension -ext WixSqlExtension -dpublishDir=$(Publish) -dMyWebResourceDir=. @(WixCode, &apos; &apos;)'
ContinueOnError="false"
WorkingDirectory="." />
<Exec
Command='"$(WixPath)light" -ext WixIISExtension -ext WixUIExtension -ext WixUtilExtension -ext WixSqlExtension -out $(MsiOut) @(WixObject, &apos; &apos;)'
ContinueOnError="false"
WorkingDirectory="." />
<!-- The list of WIX input files -->
<ItemGroup>
<WixCode Include="Product.wxs" />
<WixCode Include="$(WebSiteContentCode)" />
<WixCode Include="DemoUI.wxs" />
<WixCode Include="UIDialogs.wxs" />
<WixCode Include="IISConfiguration.wxs" />
<WixCode Include="Database.wxs" />
</ItemGroup>
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
<Fragment>
<Binary Id="CreateTablesBin" SourceFile="Database/CreateTables.sql"></Binary>
<Binary Id="FillTablesBin" SourceFile="Database/FillTables.sql"></Binary>
<util:User Id="SQLUserSA" Name="[DB_USER]" Password="[DB_PASSWORD]"></util:User>
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
<Fragment>
<Binary Id="CreateTablesBin" SourceFile="Database/CreateTables.sql"></Binary>
<Binary Id="FillTablesBin" SourceFile="Database/FillTables.sql"></Binary>
<util:User Id="SQLUserSA" Name="[DB_USER]" Password="[DB_PASSWORD]"></util:User>