Was.OrcSearch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 3  →  ?path2? @ 4
File deleted
\ No newline at end of file
/Was.OrcSearch/Helpers/Extensions.cs
/Was.OrcSearch/Metadata/AttributeMetadataCollection.cs
@@ -1,6 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Threading;
using Was.OrcSearch.Attributes;
using Was.OrcSearch.Models;
using Was.OrcSearch.Models.Interfaces;
@@ -9,7 +13,7 @@
{
public class AttributeMetadataCollection : ReflectionMetadataCollection
{
private static readonly Dictionary<Type, List<SearchableMetadata>> _propertiesCache =
private static readonly Dictionary<Type, List<SearchableMetadata>> PropertiesCache =
new Dictionary<Type, List<SearchableMetadata>>();
 
private readonly Type _targetType;
@@ -24,19 +28,16 @@
{
get
{
if (_propertiesCache.TryGetValue(_targetType, out var storedProperty))
if (PropertiesCache.TryGetValue(_targetType, out var storedProperty))
return storedProperty;
 
var searchableProperties = new List<SearchableMetadata>();
 
var properties = _targetType.GetProperties();
foreach (var property in properties)
{
var searchablePropertyAttribute =
property.GetCustomAttribute(typeof(SearchablePropertyAttribute), false) as
SearchablePropertyAttribute;
if (searchablePropertyAttribute != null)
{
if (!(property.GetCustomAttribute(typeof(SearchablePropertyAttribute), false) is
SearchablePropertyAttribute searchablePropertyAttribute)) continue;
var searchableProperty = new SearchableMetadata(property);
if (!string.IsNullOrWhiteSpace(searchablePropertyAttribute.SearchName))
searchableProperty.SearchName = searchablePropertyAttribute.SearchName;
@@ -45,9 +46,8 @@
 
searchableProperties.Add(searchableProperty);
}
}
 
_propertiesCache.Add(_targetType, searchableProperties);
PropertiesCache.Add(_targetType, searchableProperties);
return searchableProperties;
}
}
File deleted
\ No newline at end of file
/Was.OrcSearch/Services/Extensions/ISearchServiceExtensions.cs
/Was.OrcSearch/Services/SearchServiceBase.cs
@@ -9,8 +9,8 @@
using Lucene.Net.Store;
using Was.OrcSearch.EventArgs;
using Was.OrcSearch.Extensions;
using Was.OrcSearch.Helpers;
using Was.OrcSearch.Metadata.Interfaces;
using Was.OrcSearch.Services.Extensions;
using Was.OrcSearch.Services.Interfaces;
 
namespace Was.OrcSearch.Services
@@ -118,8 +118,10 @@
foreach (var searchableMetadata in searchableMetadatas)
{
var searchableMetadataValue = searchableMetadata.GetValue(searchable.Instance);
// Original: ObjectToStringHelper.ToString(searchableMetadataValue);
// TODO Support more serializable types.
 
// DEBUG
//Console.WriteLine("Stringifying: " + searchableMetadataValue);
var searchableMetadataValueAsString =
string.Join(" ", searchableMetadataValue.Stringify());
@@ -129,7 +131,7 @@
var field = new Field(searchableMetadata.SearchName, searchableMetadataValueAsString,
Field.Store.YES,
searchableMetadata.Analyze ? Field.Index.ANALYZED : Field.Index.NOT_ANALYZED,
Field.TermVector.YES);
Field.TermVector.NO);
 
document.Add(field);
 
@@ -164,8 +166,7 @@
{
foreach (var searchable in searchables)
{
int index;
if (!_searchableIndexes.TryGetValue(searchable, out index)) continue;
if (!_searchableIndexes.TryGetValue(searchable, out var index)) continue;
 
var queryAsText = $"{IndexId}:{index}";
var parser = new QueryParser(LuceneDefaults.Version, string.Empty, analyzer);
@@ -277,15 +278,15 @@
}
}
}
catch (ParseException ex)
catch (ParseException)
{
//Log.Warning(ex, "Failed to parse search pattern");
throw ex;
throw;
}
catch (Exception ex)
catch (Exception)
{
//Log.Error(ex, "An error occurred while searching, returning default results");
throw ex;
throw;
}
finally
{
/Was.OrcSearch/Was.OrcSearch.csproj
@@ -50,7 +50,6 @@
<Compile Include="EventArgs\SearchEventArgs.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Helpers\PathHelper.cs" />
<Compile Include="Helpers\Extensions.cs" />
<Compile Include="Metadata\AttributeMetadataCollection.cs" />
<Compile Include="Metadata\Interfaces\IMetadataProvider.cs" />
<Compile Include="Metadata\Interfaces\ISearchable.cs" />
@@ -78,7 +77,7 @@
<Compile Include="Models\ReflectionObjectWithMetadata.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\DummySearchNavigationService.cs" />
<Compile Include="Services\Extensions\ISearchServiceExtensions.cs" />
<Compile Include="Services\Extensions\SearchServiceExtensions.cs" />
<Compile Include="Services\InMemorySearchService.cs" />
<Compile Include="Services\Interfaces\ISearchNavigationService.cs" />
<Compile Include="Services\Interfaces\ISearchQueryService.cs" />