├── images └── logo.png ├── src ├── NHibernate.Search │ ├── NHSearch.snk │ ├── Util │ │ ├── FileHelper.cs │ │ ├── TypeHelper.cs │ │ └── ContextHelper.cs │ ├── Query │ │ ├── IteratorImpl.cs │ │ ├── ScrollableResultsImpl.cs │ │ └── FullTextFilterImpl.cs │ ├── Attributes │ │ ├── Store.cs │ │ ├── Resolution.cs │ │ ├── FilterParameterAttribute.cs │ │ ├── Indexed.cs │ │ ├── BoostAttribute.cs │ │ ├── FactoryAttribute.cs │ │ ├── KeyAttribute.cs │ │ ├── DocumentIdAttribute.cs │ │ ├── DateBridgeAttribute.cs │ │ ├── AnalyzerAttribute.cs │ │ ├── FieldBridgeAttribute.cs │ │ ├── ContainedInAttribute.cs │ │ ├── BridgeParameterAttribute.cs │ │ ├── Index.cs │ │ ├── IndexedEmbedded.cs │ │ └── FullTextFilterDefAttribute.cs │ ├── Cfg │ │ ├── nhs-configuration.xsx │ │ ├── ConfigurationSectionHandler.cs │ │ ├── INHSConfiguration.cs │ │ ├── CfgXmlHelper.cs │ │ ├── INHSConfigCollection.cs │ │ └── nhs-configuration.xsd │ ├── Backend │ │ ├── OptimizeLuceneWork.cs │ │ ├── PurgeAllLuceneWork.cs │ │ ├── DeleteLuceneWork.cs │ │ ├── AddLuceneWork.cs │ │ ├── WorkerFactory.cs │ │ ├── IQueueingProcessor.cs │ │ ├── WorkType.cs │ │ ├── IWorker.cs │ │ ├── IBackendQueueProcessorFactory.cs │ │ ├── Impl │ │ │ ├── Lucene │ │ │ │ └── LuceneBackendQueueProcessorFactory.cs │ │ │ └── PostTransactionWorkQueueSynchronization.cs │ │ ├── Work.cs │ │ ├── LuceneIndexingParameters.cs │ │ ├── LuceneWork.cs │ │ └── WorkQueue.cs │ ├── Mapping │ │ ├── Definition │ │ │ ├── IDateBridgeDefinition.cs │ │ │ ├── IFieldBridgeDefinition.cs │ │ │ └── IClassBridgeDefinition.cs │ │ ├── ContainedInMapping.cs │ │ ├── PropertyMappingBase.cs │ │ ├── ISearchMapping.cs │ │ ├── EmbeddedMapping.cs │ │ ├── ClassBridgeMapping.cs │ │ ├── FieldMapping.cs │ │ ├── AttributeBased │ │ │ └── AttributeSearchMapping.cs │ │ ├── DocumentIdMapping.cs │ │ └── DocumentMapping.cs │ ├── Bridge │ │ ├── Builtin │ │ │ ├── StringBridge.cs │ │ │ ├── GuidBridge.cs │ │ │ ├── SimpleBridge.cs │ │ │ ├── EnumBridge.cs │ │ │ └── ValueTypeBridge.cs │ │ ├── IParameterizedBridge.cs │ │ ├── IStringBridge.cs │ │ ├── ITwoWayStringBridge.cs │ │ ├── IFieldBridge.cs │ │ ├── TwoWayString2FieldBridgeAdaptor.cs │ │ ├── ITwoWayFieldBridge.cs │ │ └── String2FieldBridgeAdaptor.cs │ ├── Engine │ │ ├── ILoader.cs │ │ ├── LoaderHelper.cs │ │ ├── EntityInfo.cs │ │ └── ISearchFactoryImplementor.cs │ ├── Search.cs │ ├── Filter │ │ ├── FilterKey.cs │ │ ├── IFilterCachingStrategy.cs │ │ └── MruFilterCachingStrategy.cs │ ├── Store │ │ ├── Optimization │ │ │ ├── NoOpOptimizerStrategy.cs │ │ │ └── IOptimizerStrategy.cs │ │ ├── IDirectoryProvider.cs │ │ ├── NotShardedStrategy.cs │ │ └── IdHashShardingStrategy.cs │ ├── Async │ │ ├── Engine │ │ │ └── ILoader.cs │ │ └── Backend │ │ │ └── Impl │ │ │ └── PostTransactionWorkQueueSynchronization.cs │ ├── SearchException.cs │ ├── IFullTextFilter.cs │ ├── NHibernate.Search.Lucene.csproj │ ├── Reader │ │ ├── IReaderProvider.cs │ │ ├── ReaderProviderHelper.cs │ │ ├── CacheableMultiReader.cs │ │ └── NotSharedReaderProvider.cs │ ├── SearchRestrictions.cs │ └── ProjectionConstants.cs ├── NHibernate.Search.Tests │ ├── Query │ │ ├── LuceneQueryTest.cs │ │ ├── Author.hbm.xml │ │ ├── Clock.hbm.xml │ │ ├── AlternateBook.hbm.xml │ │ ├── Employee.hbm.xml │ │ ├── ProjectionToDelimStringResultTransformer.cs │ │ ├── Music.hbm.xml │ │ ├── Author.cs │ │ ├── Book.hbm.xml │ │ ├── Clock.cs │ │ ├── AlternateBook.cs │ │ ├── Music.cs │ │ ├── ProjectionToMapResultTransformer.cs │ │ └── Employee.cs │ ├── Embedded │ │ ├── Person.cs │ │ ├── Author.hbm.xml │ │ ├── DoubleInsert │ │ │ ├── PersonalContact.hbm.xml │ │ │ ├── BusinessContact.hbm.xml │ │ │ ├── Phone.hbm.xml │ │ │ ├── BusinessContact.cs │ │ │ ├── Address.hbm.xml │ │ │ ├── Contact.hbm.xml │ │ │ └── Phone.cs │ │ ├── Country.hbm.xml │ │ ├── Order.hbm.xml │ │ ├── Tower.hbm.xml │ │ ├── Author.cs │ │ ├── Country.cs │ │ ├── Owner.cs │ │ ├── Order.cs │ │ ├── Product.hbm.xml │ │ ├── Address.hbm.xml │ │ ├── Tower.cs │ │ ├── Product.cs │ │ └── Address.cs │ ├── Bridge │ │ ├── CloudType.cs │ │ ├── Gangster.hbm.xml │ │ ├── Department.hbm.xml │ │ ├── Departments.hbm.xml │ │ ├── Gangster.cs │ │ ├── TruncateStringBridge.cs │ │ ├── UnresolvedBridgeTest.cs │ │ ├── Cloud.hbm.xml │ │ ├── TruncateFieldBridge.cs │ │ ├── PaddedIntegerBridge.cs │ │ ├── DateSplitBridge.cs │ │ ├── CatFieldsClassBridge.cs │ │ ├── CatDeptsFieldsClassBridge.cs │ │ ├── EquipmentType.cs │ │ └── Department.cs │ ├── Session │ │ ├── Entite.cs │ │ ├── Categorie.cs │ │ ├── DelegationWrapper.cs │ │ ├── SessionTest.cs │ │ ├── Email.hbm.xml │ │ ├── Email.cs │ │ └── OptimizeTest.cs │ ├── FSDirectoryTest.cs │ ├── RamDirectoryTest.cs │ ├── Worker │ │ ├── Drink.hbm.xml │ │ ├── Food.hbm.xml │ │ ├── Employee.hbm.xml │ │ ├── Employer.hbm.xml │ │ ├── Drink.cs │ │ ├── Employee.cs │ │ ├── Employer.cs │ │ ├── Food.cs │ │ ├── SyncWorkerTest.cs │ │ ├── AsyncWorkerTest.cs │ │ └── ConcurrencyTest.cs │ ├── Inheritance │ │ ├── Animal.hbm.xml │ │ ├── Mammal.hbm.xml │ │ ├── Mammal.cs │ │ └── Animal.cs │ ├── Filter │ │ ├── ExcludeAllFilterFactory.cs │ │ ├── Soap.hbm.xml │ │ ├── Soap.cs │ │ ├── Driver.hbm.xml │ │ ├── BestDriversFilter.cs │ │ ├── ExcludeAllFilter.cs │ │ └── SecurityFilterFactory.cs │ ├── Analyzer │ │ ├── Test2Analyzer.cs │ │ ├── Test1Analyzer.cs │ │ ├── Test3Analyzer.cs │ │ ├── Test4Analyzer.cs │ │ ├── MyComponent.cs │ │ ├── MyEntity.hbm.xml │ │ ├── MyEntity.cs │ │ └── AbstractTestAnalyzer.cs │ ├── Optimizer │ │ ├── Worker.hbm.xml │ │ ├── Construction.hbm.xml │ │ ├── IncrementalOptimizerStrategyTest.cs │ │ ├── Worker.cs │ │ └── Construction.cs │ ├── DocumentTop.hbm.xml │ ├── DirectoryProvider │ │ ├── SnowStorm.hbm.xml │ │ └── SnowStorm.cs │ ├── AlternateDocument.hbm.xml │ ├── FieldAccess │ │ ├── Document.hbm.xml │ │ └── Document.cs │ ├── Reader │ │ ├── Detective.hbm.xml │ │ ├── SharedReaderPerfTest.cs │ │ ├── NotSharedReaderPerfTest.cs │ │ ├── Suspect.hbm.xml │ │ ├── Detective.cs │ │ └── Suspect.cs │ ├── LuceneWorker │ │ ├── Document.hbm.xml │ │ └── Document.cs │ ├── Shards │ │ ├── Animal.hbm.xml │ │ ├── Furniture.hbm.xml │ │ ├── Furniture.cs │ │ └── Animal.cs │ ├── Async │ │ ├── Reader │ │ │ ├── SharedReaderPerfTest.cs │ │ │ └── NotSharedReaderPerfTest.cs │ │ ├── DebugConnectionProvider.cs │ │ └── Worker │ │ │ ├── SyncWorkerTest.cs │ │ │ └── AsyncWorkerTest.cs │ ├── ListenerCfg │ │ └── ListenerRegistrationTests.cs │ ├── NHibernate.Search.Tests.csproj │ ├── Mapping │ │ └── SearchMappingFactoryTest.cs │ ├── DocumentTop.cs │ ├── log4net.config │ ├── AlternateDocument.cs │ ├── TestConfigurationHelper.cs │ └── PhysicalTestCase.cs └── Directory.Build.props ├── renovate.json ├── nugetdeploy.bat ├── README.md ├── .config └── dotnet-tools.json ├── GitVersion.yml ├── .gitattributes ├── .gitignore ├── teamcity.build ├── .github └── workflows │ ├── GenerateAsyncCode.yml │ └── test.yml └── NHibernate.Search.nuspec /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nhibernate/NHibernate-Search/HEAD/images/logo.png -------------------------------------------------------------------------------- /src/NHibernate.Search/NHSearch.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nhibernate/NHibernate-Search/HEAD/src/NHibernate.Search/NHSearch.snk -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/LuceneQueryTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nhibernate/NHibernate-Search/HEAD/src/NHibernate.Search.Tests/Query/LuceneQueryTest.cs -------------------------------------------------------------------------------- /nugetdeploy.bat: -------------------------------------------------------------------------------- 1 | nuget pack NHibernate.Search.nuspec 2 | nuget delete "NHibernate.Search" "2.0.2.4000" %1 3 | nuget push -source http://packages.nuget.org/v1/ NHibernate.Search.2.0.2.4000.nupkg %1 -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Person.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Embedded 2 | { 3 | public interface Person 4 | { 5 | string Name { get; set; } 6 | Address Address { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Util/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Util 6 | { 7 | class FileHelper 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/CloudType.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Bridge 2 | { 3 | public enum CloudType 4 | { 5 | Dragon, 6 | House, 7 | Dog, 8 | Europe 9 | } 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NHibernate.Search 2 | 3 | NHibernate Search is a port of [Hibernate Search][1]. NHibernate Search transparently indexes your objects and offers fast regular, full-text search. 4 | 5 | [1]: http://hibernate.org/search/ 6 | 7 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/Entite.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Session 6 | { 7 | class Entite 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/Categorie.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Session 6 | { 7 | class Categorie 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "csharpasyncgenerator.tool": { 6 | "version": "0.22.0", 7 | "commands": [ 8 | "async-generator" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/DelegationWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Session 6 | { 7 | class DelegationWrapper 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Query/IteratorImpl.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Query 2 | { 3 | /// 4 | /// I would guess for .NET we want this to implemnt IEnumerable 5 | /// 6 | public class IteratorImpl 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/Store.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | public enum Store 6 | { 7 | Yes, 8 | No, 9 | [Obsolete("Please use Yes")] 10 | Compress 11 | } 12 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Cfg/nhs-configuration.xsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/FSDirectoryTest.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests 2 | { 3 | using NUnit.Framework; 4 | 5 | [TestFixture] 6 | [Category("Not Implemented")] 7 | [Explicit] 8 | public class FSDirectoryTest 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/RamDirectoryTest.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests 2 | { 3 | using NUnit.Framework; 4 | 5 | [TestFixture] 6 | [Category("Not Implemented")] 7 | [Explicit] 8 | public class RamDirectoryTest 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Query/ScrollableResultsImpl.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Query 2 | { 3 | /// 4 | /// TODO: Where is (I)ScrollableResults 5 | /// 6 | public class ScrollableResultsImpl //: ScrollableResults 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/SessionTest.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Session 2 | { 3 | using NUnit.Framework; 4 | 5 | [TestFixture] 6 | [Category("Not Implemented")] 7 | [Explicit] 8 | public class SessionTest 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/OptimizeLuceneWork.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Backend 2 | { 3 | public class OptimizeLuceneWork : LuceneWork 4 | { 5 | public OptimizeLuceneWork(System.Type clazz) : base(null, null, clazz) 6 | { 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/Resolution.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Attributes 2 | { 3 | public enum Resolution 4 | { 5 | Year, 6 | Month, 7 | Day, 8 | Hour, 9 | Minute, 10 | Second, 11 | Millisecond 12 | } 13 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/PurgeAllLuceneWork.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Backend 2 | { 3 | public class PurgeAllLuceneWork : LuceneWork 4 | { 5 | public PurgeAllLuceneWork(System.Type clazz) 6 | : base(null, null, clazz, null) 7 | { 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/Definition/IDateBridgeDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using NHibernate.Search.Attributes; 4 | 5 | namespace NHibernate.Search.Mapping.Definition 6 | { 7 | public interface IDateBridgeDefinition 8 | { 9 | Resolution Resolution { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/Builtin/StringBridge.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Bridge.Builtin 2 | { 3 | public class StringBridge : SimpleBridge 4 | { 5 | public override object StringToObject(string stringValue) 6 | { 7 | return stringValue; 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/DeleteLuceneWork.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Backend 2 | { 3 | public class DeleteLuceneWork : LuceneWork 4 | { 5 | public DeleteLuceneWork(object id, string idInString, System.Type clazz) 6 | : base(id, idInString, clazz) 7 | { 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/Builtin/GuidBridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Bridge.Builtin 4 | { 5 | public class GuidBridge : SimpleBridge 6 | { 7 | 8 | public override object StringToObject(string stringValue) 9 | { 10 | return new Guid(stringValue); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/Definition/IFieldBridgeDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NHibernate.Search.Mapping.Definition 5 | { 6 | public interface IFieldBridgeDefinition 7 | { 8 | System.Type Impl { get; } 9 | Dictionary Parameters { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/FilterParameterAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Attributes 2 | { 3 | using System; 4 | 5 | /// 6 | /// Defines a parameter on a filter 7 | /// 8 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] 9 | public class FilterParameterAttribute : Attribute 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/AddLuceneWork.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Documents; 2 | 3 | namespace NHibernate.Search.Backend 4 | { 5 | public class AddLuceneWork : LuceneWork 6 | { 7 | public AddLuceneWork(object id, string idInString, System.Type clazz, Document document) 8 | : base(id, idInString, clazz, document) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/IParameterizedBridge.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NHibernate.Search.Bridge 4 | { 5 | /// 6 | /// Allow parameter injection to a given bridge 7 | /// 8 | public interface IParameterizedBridge 9 | { 10 | void SetParameterValues(Dictionary parameters); 11 | } 12 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Engine/ILoader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace NHibernate.Search.Engine 4 | { 5 | public partial interface ILoader 6 | { 7 | void Init(ISession session, ISearchFactoryImplementor searchFactoryImplementor); 8 | 9 | object Load(EntityInfo entityInfo); 10 | 11 | IList Load(EntityInfo[] entityInfos); 12 | } 13 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/ContainedInMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using NHibernate.Properties; 5 | 6 | namespace NHibernate.Search.Mapping 7 | { 8 | public class ContainedInMapping : PropertyMappingBase 9 | { 10 | public ContainedInMapping(IGetter getter) : base(getter) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Search.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Impl; 2 | 3 | namespace NHibernate.Search 4 | { 5 | public static class Search 6 | { 7 | public static IFullTextSession CreateFullTextSession(ISession session) 8 | { 9 | return session as FullTextSessionImpl ?? 10 | new FullTextSessionImpl(session); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /GitVersion.yml: -------------------------------------------------------------------------------- 1 | assembly-versioning-scheme: MajorMinor 2 | mode: ContinuousDeployment 3 | major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)" 4 | minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:" 5 | patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:" -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Author.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Clock.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Drink.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Food.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/Gangster.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Author.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/PersonalContact.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Employee.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Employer.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Country.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Inheritance/Animal.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/ExcludeAllFilterFactory.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Search; 2 | using NHibernate.Search.Attributes; 3 | 4 | namespace NHibernate.Search.Tests.Filter 5 | { 6 | public class ExcludeAllFilterFactory 7 | { 8 | [Factory] 9 | public Lucene.Net.Search.Filter GetFilter() 10 | { 11 | return new CachingWrapperFilter(new ExcludeAllFilter()); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/Soap.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/AlternateBook.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Order.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/Indexed.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 6 | public class IndexedAttribute : Attribute 7 | { 8 | private string index = string.Empty; 9 | 10 | public string Index 11 | { 12 | get { return index; } 13 | set { index = value; } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/PropertyMappingBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using NHibernate.Properties; 5 | 6 | namespace NHibernate.Search.Mapping 7 | { 8 | public class PropertyMappingBase 9 | { 10 | protected PropertyMappingBase(IGetter getter) 11 | { 12 | this.Getter = getter; 13 | } 14 | 15 | public IGetter Getter { get; private set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/Test2Analyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Analyzer 6 | { 7 | public class Test2Analyzer : AbstractTestAnalyzer 8 | { 9 | private string[] tokens = { "sound", "cat", "speed" }; 10 | 11 | protected override string[] Tokens 12 | { 13 | get { return tokens; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Optimizer/Worker.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/ISearchMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | using NHibernate.Cfg; 6 | using NHibernate.Search.Mapping.Definition; 7 | 8 | namespace NHibernate.Search.Mapping 9 | { 10 | using Type = System.Type; 11 | 12 | public interface ISearchMapping 13 | { 14 | ICollection Build(Configuration cfg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/Test1Analyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Analyzer 6 | { 7 | public class Test1Analyzer : AbstractTestAnalyzer 8 | { 9 | private string[] tokens = { "alarm", "dog", "performance" }; 10 | 11 | protected override string[] Tokens 12 | { 13 | get { return tokens; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/Test3Analyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Analyzer 6 | { 7 | public class Test3Analyzer : AbstractTestAnalyzer 8 | { 9 | private string[] tokens = { "music", "elephant", "energy" }; 10 | 11 | protected override string[] Tokens 12 | { 13 | get { return tokens; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/Test4Analyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace NHibernate.Search.Tests.Analyzer 6 | { 7 | public class Test4Analyzer : AbstractTestAnalyzer 8 | { 9 | private string[] tokens = { "noise", "mouse", "light" }; 10 | 11 | protected override string[] Tokens 12 | { 13 | get { return tokens; } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Inheritance/Mammal.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Optimizer/Construction.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Employee.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/DocumentTop.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/DirectoryProvider/SnowStorm.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Inheritance/Mammal.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Inheritance 4 | { 5 | public class Mammal : Animal 6 | { 7 | private int numberOfLegs; 8 | 9 | [Field(Index.UnTokenized, Store = Attributes.Store.Yes)] 10 | public virtual int NumberOfLegs 11 | { 12 | get { return numberOfLegs; } 13 | set { numberOfLegs = value; } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/Email.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/BusinessContact.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/Builtin/SimpleBridge.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Bridge.Builtin 2 | { 3 | public abstract class SimpleBridge : ITwoWayStringBridge 4 | { 5 | #region ITwoWayStringBridge Members 6 | 7 | public abstract object StringToObject(string stringValue); 8 | 9 | public virtual string ObjectToString(object obj) 10 | { 11 | return obj == null ? null : obj.ToString(); 12 | } 13 | 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/AlternateDocument.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/FieldAccess/Document.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Reader/Detective.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Reader/SharedReaderPerfTest.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Cfg; 2 | using NUnit.Framework; 3 | 4 | namespace NHibernate.Search.Tests.Reader 5 | { 6 | [TestFixture] 7 | public class SharedReaderPerfTest : ReaderPerfTestCase 8 | { 9 | protected override void Configure(Configuration configuration) 10 | { 11 | base.Configure(configuration); 12 | configuration.SetProperty(Environment.ReaderStrategy, "shared"); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/MyComponent.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Analyzer 4 | { 5 | public class MyComponent 6 | { 7 | [Field(Index.Tokenized)] 8 | [Analyzer(typeof(Test4Analyzer))] 9 | private string componentProperty; 10 | 11 | public string ComponentProperty 12 | { 13 | get { return componentProperty; } 14 | set { componentProperty = value; } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/LuceneWorker/Document.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Reader/NotSharedReaderPerfTest.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Cfg; 2 | using NUnit.Framework; 3 | 4 | namespace NHibernate.Search.Tests.Reader 5 | { 6 | [TestFixture] 7 | public class NotSharedReaderPerfTest : ReaderPerfTestCase 8 | { 9 | protected override void Configure(Configuration configuration) 10 | { 11 | base.Configure(configuration); 12 | configuration.SetProperty(Environment.ReaderStrategy, "not-shared"); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/Builtin/EnumBridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Bridge.Builtin 4 | { 5 | public class EnumBridge : SimpleBridge 6 | { 7 | private readonly System.Type type; 8 | 9 | public EnumBridge(System.Type type) 10 | { 11 | this.type = type; 12 | } 13 | 14 | public override object StringToObject(string stringValue) 15 | { 16 | return Enum.Parse(type, stringValue); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/IStringBridge.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Bridge 2 | { 3 | /// 4 | /// Transform an object into a string representation 5 | /// 6 | public interface IStringBridge 7 | { 8 | /// 9 | /// Convert the object representation to a String 10 | /// The return String must not be null, it can be empty though 11 | /// 12 | string ObjectToString(object obj); 13 | } 14 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Tower.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Reader/Suspect.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Shards/Animal.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/Department.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Shards/Furniture.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/Soap.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Filter 4 | { 5 | public class Soap 6 | { 7 | [DocumentId] private int id; 8 | private string perfume; 9 | 10 | public int Id 11 | { 12 | get { return id; } 13 | set { id = value; } 14 | } 15 | 16 | public string Perfume 17 | { 18 | get { return perfume; } 19 | set { perfume = value; } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/Departments.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/ProjectionToDelimStringResultTransformer.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Query 2 | { 3 | using System.Collections; 4 | 5 | using Transform; 6 | 7 | public class ProjectionToDelimStringResultTransformer : IResultTransformer 8 | { 9 | public object TransformTuple(object[] tuple, string[] aliases) 10 | { 11 | return string.Join(", ", tuple); 12 | } 13 | 14 | public IList TransformList(IList collection) 15 | { 16 | return collection; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/WorkerFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using NHibernate.Cfg; 3 | using NHibernate.Search.Backend.Impl; 4 | using NHibernate.Search.Impl; 5 | 6 | namespace NHibernate.Search.Backend 7 | { 8 | public static class WorkerFactory 9 | { 10 | public static IWorker CreateWorker(Configuration cfg, SearchFactoryImpl searchFactory) 11 | { 12 | IWorker worker = new TransactionalWorker(); 13 | worker.Initialize((IDictionary)cfg.Properties, searchFactory); 14 | return worker; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/MyEntity.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Optimizer/IncrementalOptimizerStrategyTest.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Cfg; 2 | using NUnit.Framework; 3 | 4 | namespace NHibernate.Search.Tests.Optimizer 5 | { 6 | [TestFixture] 7 | [Ignore("Does not complete")] 8 | public class IncrementalOptimizerStrategyTest : OptimizerTestCase 9 | { 10 | protected override void Configure(Configuration configuration) 11 | { 12 | base.Configure(configuration); 13 | configuration.SetProperty("hibernate.search.default.optimizer.transaction_limit.max", "10"); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Shards/Furniture.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Shards 4 | { 5 | [Indexed] 6 | public class Furniture 7 | { 8 | [DocumentId] 9 | private int id; 10 | [Field] 11 | private string color; 12 | 13 | public int Id 14 | { 15 | get { return id; } 16 | set { id = value; } 17 | } 18 | 19 | public string Color 20 | { 21 | get { return color; } 22 | set { color = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/Definition/IClassBridgeDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NHibernate.Search.Attributes; 4 | 5 | namespace NHibernate.Search.Mapping.Definition 6 | { 7 | using Type = System.Type; 8 | 9 | public interface IClassBridgeDefinition 10 | { 11 | string Name { get; } 12 | Attributes.Store Store { get; } 13 | Index Index { get; } 14 | Type Analyzer { get; } 15 | float Boost { get; } 16 | Type Impl { get; } 17 | Dictionary Parameters { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Music.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Author.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Embedded 4 | { 5 | public class Author 6 | { 7 | [DocumentId] 8 | private int id; 9 | 10 | [Field(Index.Tokenized)] 11 | private string name; 12 | 13 | public virtual int Id 14 | { 15 | get { return id; } 16 | set { id = value; } 17 | } 18 | 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Author.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Query 4 | { 5 | [Indexed] 6 | public class Author 7 | { 8 | [DocumentId] 9 | private int id; 10 | private string name; 11 | 12 | public virtual int Id 13 | { 14 | get { return id; } 15 | set { id = value; } 16 | } 17 | 18 | [Field(Index.Tokenized)] 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Country.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Embedded 4 | { 5 | [Indexed] 6 | public class Country 7 | { 8 | [DocumentId] 9 | private int id; 10 | 11 | [Field] 12 | private string name; 13 | 14 | public virtual int Id 15 | { 16 | get { return id; } 17 | set { id = value; } 18 | } 19 | 20 | public virtual string Name 21 | { 22 | get { return name; } 23 | set { name = value; } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Shards/Animal.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Shards 4 | { 5 | [Indexed(Index = "Animal")] 6 | public class Animal 7 | { 8 | [DocumentId] 9 | private int id; 10 | [Field(Index.Tokenized)] 11 | private string name; 12 | 13 | public int Id 14 | { 15 | get { return id; } 16 | set { id = value; } 17 | } 18 | 19 | public string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Cfg/ConfigurationSectionHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Xml; 3 | 4 | namespace NHibernate.Search.Cfg 5 | { 6 | public class ConfigurationSectionHandler : IConfigurationSectionHandler 7 | { 8 | #region IConfigurationSectionHandler Members 9 | 10 | public object Create(object parent, object configContext, XmlNode section) 11 | { 12 | XmlTextReader reader = new XmlTextReader(section.OuterXml, XmlNodeType.Document, null); 13 | return new NHSConfigCollection(reader); 14 | } 15 | 16 | #endregion 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Drink.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Worker 4 | { 5 | [Indexed(Index = "consumable")] 6 | public class Drink 7 | { 8 | private int id; 9 | private string name; 10 | 11 | [DocumentId] 12 | public virtual int Id 13 | { 14 | get { return id; } 15 | set { id = value; } 16 | } 17 | 18 | [Field(Index.Tokenized)] 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/IQueueingProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Backend 2 | { 3 | /// 4 | /// Pile work operations 5 | /// No thread safety has to be implemented, the queue being thread scoped already 6 | /// The implementation must be "stateless" wrt the queue through (ie not store the queue state) 7 | /// 8 | public interface IQueueingProcessor 9 | { 10 | void PerformWorks(WorkQueue workQueue); 11 | void CancelWorks(WorkQueue workQueue); 12 | void Add(Work work, WorkQueue workQueue); 13 | void PrepareWorks(WorkQueue workQueue); 14 | } 15 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Util/TypeHelper.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Util 2 | { 3 | /// 4 | /// Utilities for types 5 | /// 6 | internal static class TypeHelper 7 | { 8 | /// 9 | /// Includes the name of the type and it's assembly so we load it, but are not tied to the specific version 10 | /// 11 | /// 12 | /// 13 | public static string LuceneTypeName(System.Type type) 14 | { 15 | return type.FullName + ", " + type.Assembly.GetName().Name; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Employee.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Worker 4 | { 5 | [Indexed(Index = "employee")] 6 | public class Employee 7 | { 8 | private int id; 9 | private string name; 10 | 11 | [DocumentId] 12 | public virtual int Id 13 | { 14 | get { return id; } 15 | set { id = value; } 16 | } 17 | 18 | [Field(Index.Tokenized)] 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Employer.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Worker 4 | { 5 | [Indexed(Index = "employer")] 6 | public class Employer 7 | { 8 | private int id; 9 | private string name; 10 | 11 | [DocumentId] 12 | public virtual int Id 13 | { 14 | get { return id; } 15 | set { id = value; } 16 | } 17 | 18 | [Field(Index.Tokenized)] 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/Food.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Worker 4 | { 5 | [Indexed(Index = "consumable")] 6 | public class Food 7 | { 8 | private int id; 9 | private string name; 10 | 11 | [DocumentId] 12 | public virtual int Id 13 | { 14 | get { return id; } 15 | set { id = value; } 16 | } 17 | 18 | [Field(Index.Tokenized)] 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/Phone.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Inheritance/Animal.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Inheritance 4 | { 5 | [Indexed] 6 | public class Animal 7 | { 8 | private int id; 9 | private string name; 10 | 11 | [DocumentId] 12 | public virtual int Id 13 | { 14 | get { return id; } 15 | set { id = value; } 16 | } 17 | 18 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)] 19 | public virtual string Name 20 | { 21 | get { return name; } 22 | set { name = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Owner.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Embedded 4 | { 5 | public class Owner : Person 6 | { 7 | [Field(Index.Tokenized)] 8 | private string name; 9 | 10 | [IndexedEmbedded] // play the lunatic user 11 | private Address address; 12 | 13 | public virtual string Name 14 | { 15 | get { return name; } 16 | set { name = value; } 17 | } 18 | 19 | public virtual Address Address 20 | { 21 | get { return address; } 22 | set { address = value; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/BoostAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Applies a boost factor on a field or whole entity 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 9 | public class BoostAttribute : Attribute 10 | { 11 | private readonly float value; 12 | 13 | public BoostAttribute(float value) 14 | { 15 | this.value = value; 16 | } 17 | 18 | public float Value 19 | { 20 | get { return value; } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/EmbeddedMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NHibernate.Properties; 4 | 5 | namespace NHibernate.Search.Mapping 6 | { 7 | public class EmbeddedMapping : PropertyMappingBase 8 | { 9 | public EmbeddedMapping(DocumentMapping @class, IGetter getter) : base(getter) 10 | { 11 | this.Class = @class; 12 | this.Prefix = string.Empty; 13 | 14 | this.IsCollection = true; 15 | } 16 | 17 | public DocumentMapping Class { get; private set; } 18 | public string Prefix { get; set; } 19 | public bool IsCollection { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/FactoryAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Marks a method as a factory method for a given type. 7 | /// A factory method is called whenever a new instance of a given 8 | /// type is requested. 9 | /// The factory method is used with a higher priority than a plain no-arg constructor when present 10 | /// 11 | /// Factory currently works for classes supplied to . 12 | /// 13 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 14 | public class FactoryAttribute : Attribute 15 | { 16 | } 17 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Book.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.cs text diff=csharp 7 | *.xaml text 8 | *.txt text 9 | *.tt text 10 | *.ps1 text 11 | *.cmd text 12 | *.msbuild text 13 | *.md text 14 | 15 | *.sln text eol=crlf 16 | *.csproj text eol=crlf 17 | *.vbproj text eol=crlf 18 | *.fsproj text eol=crlf 19 | *.dbproj text eol=crlf 20 | 21 | # Resharper DotSettings files are in Unix format 22 | *.DotSettings text eol=lf 23 | 24 | # Binary files 25 | *.png binary 26 | *.jpg binary 27 | *.dll binary 28 | *.exe binary 29 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Order.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Embedded 4 | { 5 | public class Order 6 | { 7 | [DocumentId] 8 | private int id; 9 | 10 | [Field(Index.UnTokenized)] 11 | private string orderNumber; 12 | 13 | public virtual int Id 14 | { 15 | get { return id; } 16 | set { id = value; } 17 | } 18 | 19 | /// 20 | /// 21 | /// 22 | public virtual string OrderNumber 23 | { 24 | get { return orderNumber; } 25 | set { orderNumber = value; } 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/Gangster.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Bridge 4 | { 5 | [Indexed] 6 | public class Gangster 7 | { 8 | private System.Type id; 9 | private string name; 10 | 11 | /// 12 | /// 13 | /// 14 | [DocumentId] 15 | public virtual System.Type Id 16 | { 17 | get { return id; } 18 | set { id = value; } 19 | } 20 | 21 | /// 22 | /// 23 | /// 24 | public virtual string Name 25 | { 26 | get { return name; } 27 | set { name = value; } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/Driver.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/KeyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Marks a method as a key constructor for a given type. 7 | /// A key is an object that uniquely identify a given object type and a given set of parameters 8 | /// 9 | /// The key object must implement equals / hashcode so that 2 keys are equals iif 10 | /// the given target object types are the same, the set of parameters are the same. 11 | /// 12 | /// KeyAttribute currently works for 13 | /// 14 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 15 | public class KeyAttribute : Attribute 16 | { 17 | } 18 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/DocumentIdAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Declare a field as the document id. If set to a property, the property will be used 7 | /// Note that must return the Entity id 8 | /// 9 | /// TODO: If set to a class, the class itself will be passed to the FieldBridge 10 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 11 | public class DocumentIdAttribute : Attribute 12 | { 13 | private string name = null; 14 | 15 | public string Name 16 | { 17 | get { return name; } 18 | set { name = value; } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Product.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/BestDriversFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lucene.Net.Index; 3 | using Lucene.Net.Search; 4 | using Lucene.Net.Util; 5 | 6 | namespace NHibernate.Search.Tests.Filter 7 | { 8 | public class BestDriversFilter : Lucene.Net.Search.Filter 9 | { 10 | public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) 11 | { 12 | throw new NotImplementedException(); 13 | //BitArray bitArray = new BitArray(reader.MaxDoc()); 14 | //TermDocs termDocs = reader.TermDocs(new Term("score", "5")); 15 | //while (termDocs.Next()) 16 | //{ 17 | // bitArray.Set(termDocs.Doc(), true); 18 | //} 19 | 20 | //return bitArray; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore file for Visual Studio 2008/2010 2 | 3 | *.obj 4 | *.exe 5 | *.pdb 6 | *.user 7 | *.aps 8 | *.pch 9 | *.vspscc 10 | *_i.c 11 | *_p.c 12 | *.ncb 13 | *.suo 14 | *.tlb 15 | *.tlh 16 | *.bak 17 | *.cache 18 | *.ilk 19 | *.log 20 | *.lib 21 | *.sbr 22 | *.scc 23 | *.tokens 24 | *.csdat 25 | [Bb]in 26 | [Db]ebug*/ 27 | obj/ 28 | packages/ 29 | [Rr]elease*/ 30 | *resharper* 31 | _ReSharper*/ 32 | [Tt]est[Rr]esult* 33 | [Bb]uild[Ll]og.* 34 | *.[Pp]ublish.xml 35 | NHibernate.dll 36 | build/ 37 | AssemblyInfo.cs 38 | hibernate.cfg.xml 39 | available-test-configurations 40 | current-test-configuration 41 | NHibernate.VisualState.xml 42 | .vs/ 43 | .idea/ 44 | consumable/ 45 | employee/ 46 | employer/ 47 | lucenedirs/ 48 | slave/ 49 | master/ 50 | indextemp/ 51 | filehelperdest/ 52 | nhibernate.db 53 | coverage/ -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/WorkType.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Backend 2 | { 3 | /// 4 | /// Enumeration of different types of Lucene work. This enumeration is used to specify the type of 5 | /// index operation to be executed. 6 | /// 7 | public enum WorkType 8 | { 9 | Add, 10 | Update, 11 | Delete, 12 | Collection, 13 | /// 14 | /// Used to remove a specific instance of a class from an index. 15 | /// 16 | Purge, 17 | /// 18 | /// Used to remove all instances of a class from an index. 19 | /// 20 | PurgeAll, 21 | /// 22 | /// Used for batch indexing. 23 | /// 24 | Index 25 | } 26 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/ITwoWayStringBridge.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Bridge 2 | { 3 | /// 4 | /// IStringBridge allowing a translation from the string back to the object 5 | /// ObjectToString( StringToObject( string ) ) and StringToObject( objectToString( object ) ) 6 | /// should be "idempotent". More precisely, 7 | /// 8 | /// ObjectToString( stringToObject( string ) ).Equals(string) for string not null 9 | /// StringToObject( objectToString( object ) ).Equals(object) for object not null 10 | /// 11 | public interface ITwoWayStringBridge : IStringBridge 12 | { 13 | /// 14 | /// Convert the string representation to an object 15 | /// 16 | object StringToObject(string stringValue); 17 | } 18 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/BusinessContact.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Embedded.DoubleInsert 2 | { 3 | using Attributes; 4 | 5 | [Indexed] 6 | public class BusinessContact : Contact 7 | { 8 | [Field(Index = Index.Tokenized, Store = Store.Yes)] 9 | private string businessName; 10 | 11 | [Field(Index = Index.Tokenized, Store = Store.Yes)] 12 | private string url; 13 | 14 | public string BusinessName 15 | { 16 | get { return this.businessName; } 17 | set { this.businessName = value; } 18 | } 19 | 20 | public string Url 21 | { 22 | get { return string.IsNullOrEmpty(this.url) ? "Not provided" : this.url; } 23 | set { this.url = value; } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/DateBridgeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NHibernate.Search.Mapping.Definition; 3 | 4 | namespace NHibernate.Search.Attributes 5 | { 6 | /// 7 | /// Defines the temporal resolution of a given field 8 | /// Date are stored as String in GMT 9 | /// 10 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 11 | public class DateBridgeAttribute : Attribute, IDateBridgeDefinition 12 | { 13 | private readonly Resolution resolution; 14 | 15 | public DateBridgeAttribute(Resolution resolution) 16 | { 17 | this.resolution = resolution; 18 | } 19 | 20 | public Resolution Resolution 21 | { 22 | get { return resolution; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Address.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/Address.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/ExcludeAllFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using Lucene.Net.Index; 4 | using Lucene.Net.Search; 5 | using Lucene.Net.Util; 6 | 7 | namespace NHibernate.Search.Tests.Filter 8 | { 9 | public class ExcludeAllFilter : Lucene.Net.Search.Filter 10 | { 11 | //private static bool done = false; 12 | 13 | public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) 14 | { 15 | throw new NotImplementedException(); 16 | //if (done) 17 | //{ 18 | // throw new NotSupportedException("Called twice"); 19 | //} 20 | 21 | //BitArray bitArray = new BitArray(reader.MaxDoc()); 22 | //done = true; 23 | 24 | //return bitArray; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/AnalyzerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Defines an analyzer for a given entity, method or field. 7 | /// The order of precedence is 8 | /// - FieldAttribute 9 | /// - field / method 10 | /// - entity 11 | /// - default 12 | /// 13 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 14 | public class AnalyzerAttribute : Attribute 15 | { 16 | private readonly System.Type type; 17 | 18 | public AnalyzerAttribute(System.Type value) 19 | { 20 | type = value; 21 | } 22 | 23 | public System.Type Type 24 | { 25 | get { return type; } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Clock.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Query 2 | { 3 | using Attributes; 4 | 5 | [Indexed] 6 | public class Clock 7 | { 8 | private string brand; 9 | 10 | private int id; 11 | 12 | public Clock() 13 | { 14 | } 15 | 16 | public Clock(int id, string brand) 17 | { 18 | this.id = id; 19 | this.brand = brand; 20 | } 21 | 22 | [DocumentId] 23 | public virtual int Id 24 | { 25 | get { return this.id; } 26 | set { this.id = value; } 27 | } 28 | 29 | [Field(Index.Tokenized, Store = Store.Yes)] 30 | public virtual string Brand 31 | { 32 | get { return this.brand; } 33 | set { this.brand = value; } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Filter/FilterKey.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Filter 2 | { 3 | /// 4 | /// The key object must implement equals / hashcode so that 2 keys are equals if and only if 5 | /// the given Filter types are the same and the set of parameters are the same. 6 | /// 7 | /// The FilterKey creator (ie the @Key method) does not have to inject impl 8 | /// It will be done by Hibernate Search 9 | /// 10 | /// 11 | public abstract class FilterKey 12 | { 13 | private System.Type impl; 14 | 15 | /// 16 | /// Represent the @FullTextFilterDef.impl class 17 | /// 18 | public virtual System.Type Impl 19 | { 20 | get { return impl; } 21 | set { impl = value; } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Tower.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Embedded 4 | { 5 | [Indexed] 6 | public class Tower 7 | { 8 | [DocumentId] 9 | private long id; 10 | 11 | [Field(Index.Tokenized)] 12 | private string name; 13 | 14 | [IndexedEmbedded] 15 | private Address address; 16 | 17 | public virtual long Id 18 | { 19 | get { return id; } 20 | set { id = value; } 21 | } 22 | 23 | public virtual string Name 24 | { 25 | get { return name; } 26 | set { name = value; } 27 | } 28 | 29 | public virtual Address Address 30 | { 31 | get { return address; } 32 | set { address = value; } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /teamcity.build: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | This build file is for use with CruiseControl.NET or TeamCity 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Store/Optimization/NoOpOptimizerStrategy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NHibernate.Search.Backend; 3 | using NHibernate.Search.Engine; 4 | 5 | namespace NHibernate.Search.Store.Optimization 6 | { 7 | public class NoOpOptimizerStrategy : IOptimizerStrategy 8 | { 9 | public bool NeedOptimization 10 | { 11 | get { return false; } 12 | } 13 | 14 | public void Initialize(IDirectoryProvider directoryProvider, IDictionary indexProperties, ISearchFactoryImplementor searchFactoryImplementor) 15 | { 16 | } 17 | 18 | public void OptimizationForced() 19 | { 20 | } 21 | 22 | public void AddTransaction(long theOperations) 23 | { 24 | } 25 | 26 | public void Optimize(Workspace workspace) 27 | { 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/IWorker.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using NHibernate.Engine; 3 | using NHibernate.Search.Impl; 4 | 5 | namespace NHibernate.Search.Backend 6 | { 7 | /// 8 | /// Perform work for a given session. This implementation has to be multi threaded 9 | /// 10 | public interface IWorker 11 | { 12 | /// 13 | /// Perform the work on the session 14 | /// 15 | /// 16 | /// 17 | void PerformWork(Work work, ISessionImplementor session); 18 | 19 | /// 20 | /// Initialize the worker 21 | /// 22 | /// 23 | /// 24 | void Initialize(IDictionary props, SearchFactoryImpl searchFactory); 25 | } 26 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Async/Engine/ILoader.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using System.Collections; 12 | 13 | namespace NHibernate.Search.Engine 14 | { 15 | using System.Threading.Tasks; 16 | using System.Threading; 17 | public partial interface ILoader 18 | { 19 | 20 | Task LoadAsync(EntityInfo entityInfo, CancellationToken cancellationToken = default(CancellationToken)); 21 | 22 | Task LoadAsync(EntityInfo[] entityInfos, CancellationToken cancellationToken = default(CancellationToken)); 23 | } 24 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/SyncWorkerTest.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Analysis.Core; 2 | using NHibernate.Cfg; 3 | using NUnit.Framework; 4 | 5 | namespace NHibernate.Search.Tests.Worker 6 | { 7 | [TestFixture] 8 | public class SyncWorkerTest : WorkerTestCase 9 | { 10 | protected override void Configure(Configuration configuration) 11 | { 12 | base.Configure(configuration); 13 | configuration.SetProperty("hibernate.search.default.directory_provider", typeof(Store.RAMDirectoryProvider).AssemblyQualifiedName); 14 | configuration.SetProperty(Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName); 15 | configuration.SetProperty(Environment.WorkerScope, "transaction"); 16 | configuration.SetProperty(Environment.WorkerExecution, "sync"); // Note: It is WorkerPrefix in the Java version, but it must be a typo 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/AlternateBook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Tests.Query 4 | { 5 | using Attributes; 6 | 7 | [Indexed(Index = "Book")] 8 | public class AlternateBook 9 | { 10 | private int id; 11 | private String summary; 12 | 13 | public AlternateBook() 14 | { 15 | } 16 | 17 | public AlternateBook(int id, string summary) 18 | { 19 | this.id = id; 20 | this.summary = summary; 21 | } 22 | 23 | [DocumentId] 24 | public virtual int Id 25 | { 26 | get { return id; } 27 | set { id = value; } 28 | } 29 | 30 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)] 31 | public virtual string Summary 32 | { 33 | get { return summary; } 34 | set { summary = value; } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/IBackendQueueProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | 5 | namespace NHibernate.Search.Backend 6 | { 7 | using Engine; 8 | 9 | /// 10 | /// Build stateful backend processor 11 | /// Must have a no arg constructor 12 | /// The factory typically prepare or pool the resources needed by the queue processor 13 | /// 14 | public interface IBackendQueueProcessorFactory 15 | { 16 | void Initialize(IDictionary props, ISearchFactoryImplementor aSearchFactory); 17 | 18 | /// 19 | /// Return a runnable implementation responsible for processing the queue to a given backend 20 | /// 21 | /// 22 | /// 23 | WaitCallback GetProcessor(IList queue); 24 | } 25 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/Impl/Lucene/LuceneBackendQueueProcessorFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | 5 | namespace NHibernate.Search.Backend.Impl.Lucene 6 | { 7 | using Engine; 8 | 9 | public class LuceneBackendQueueProcessorFactory : IBackendQueueProcessorFactory 10 | { 11 | private ISearchFactoryImplementor searchFactoryImplementor; 12 | 13 | #region IBackendQueueProcessorFactory Members 14 | 15 | public void Initialize(IDictionary props, ISearchFactoryImplementor searchFactoryImplementor) 16 | { 17 | this.searchFactoryImplementor = searchFactoryImplementor; 18 | } 19 | 20 | public WaitCallback GetProcessor(IList queue) 21 | { 22 | return new LuceneBackendQueueProcessor(queue, searchFactoryImplementor).Run; 23 | } 24 | 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Music.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Iesi.Collections.Generic; 3 | using NHibernate.Search.Attributes; 4 | 5 | namespace NHibernate.Search.Tests.Query 6 | { 7 | [Indexed] 8 | public class Music 9 | { 10 | private long id; 11 | private string title; 12 | private ISet authors = new HashSet(); 13 | 14 | [DocumentId] 15 | public virtual long Id 16 | { 17 | get { return id; } 18 | set { id = value; } 19 | } 20 | 21 | [IndexedEmbedded(Depth = 1)] 22 | public virtual ISet Authors 23 | { 24 | get { return authors; } 25 | } 26 | 27 | [Field(Name = "title", Index = Index.Tokenized)] 28 | public virtual string Title 29 | { 30 | get { return title; } 31 | set { title = value; } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/IFieldBridge.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Documents; 2 | 3 | namespace NHibernate.Search.Bridge 4 | { 5 | /// 6 | /// Link between a .NET property and a Lucene Document 7 | /// Usually a .NET property will be linked to a Document Field 8 | /// 9 | /// TODO: should show Field or document - document is nice since I can save an object into several fields 10 | public interface IFieldBridge 11 | { 12 | /// 13 | /// Manipulate the document to index the given value. 14 | /// A common implementation is to add a Field name to the given document following 15 | /// the parameters (store, index, boost) if the 16 | /// value is not null 17 | /// 18 | void Set(string name, object value, Document document, FieldType fieldType, float? boost); 19 | } 20 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Async/Reader/SharedReaderPerfTest.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using NHibernate.Cfg; 12 | using NUnit.Framework; 13 | 14 | namespace NHibernate.Search.Tests.Reader 15 | { 16 | using System.Threading.Tasks; 17 | [TestFixture] 18 | public class SharedReaderPerfTestAsync : ReaderPerfTestCaseAsync 19 | { 20 | protected override void Configure(Configuration configuration) 21 | { 22 | base.Configure(configuration); 23 | configuration.SetProperty(Environment.ReaderStrategy, "shared"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/ListenerCfg/ListenerRegistrationTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NHibernate.Search.Event; 4 | 5 | using NUnit.Framework; 6 | 7 | namespace NHibernate.Search.Tests.ListenerCfg 8 | { 9 | [TestFixture] 10 | public class ListenerRegistrationTests : SearchTestCase 11 | { 12 | protected override IEnumerable Mappings 13 | { 14 | get 15 | { 16 | return new string[0]; 17 | } 18 | } 19 | 20 | [Test] 21 | public void PostInsertEventListenerTest() 22 | { 23 | Assert.AreEqual(1, this.cfg.EventListeners.PostInsertEventListeners.Length); 24 | Assert.IsTrue(this.cfg.EventListeners.PostInsertEventListeners[0] is FullTextIndexEventListener); 25 | Assert.Greater(this.cfg.EventListeners.PostInsertEventListeners.Length, 0); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/ProjectionToMapResultTransformer.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Query 2 | { 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | using Transform; 7 | 8 | public class ProjectionToMapResultTransformer : IResultTransformer 9 | { 10 | public object TransformTuple(object[] tuple, string[] aliases) 11 | { 12 | Dictionary result = new Dictionary(); 13 | 14 | for (int i = 0; i < tuple.Length; i++) 15 | { 16 | string key = aliases[i]; 17 | if (!string.IsNullOrEmpty(key)) 18 | { 19 | result[key] = tuple[i]; 20 | } 21 | } 22 | 23 | return result; 24 | } 25 | 26 | public IList TransformList(IList collection) 27 | { 28 | return collection; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Async/Reader/NotSharedReaderPerfTest.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using NHibernate.Cfg; 12 | using NUnit.Framework; 13 | 14 | namespace NHibernate.Search.Tests.Reader 15 | { 16 | using System.Threading.Tasks; 17 | [TestFixture] 18 | public class NotSharedReaderPerfTestAsync : ReaderPerfTestCaseAsync 19 | { 20 | protected override void Configure(Configuration configuration) 21 | { 22 | base.Configure(configuration); 23 | configuration.SetProperty(Environment.ReaderStrategy, "not-shared"); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/ClassBridgeMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Lucene.Net.Analysis; 4 | using Lucene.Net.Analysis.Core; 5 | using NHibernate.Search.Attributes; 6 | using NHibernate.Search.Bridge; 7 | 8 | namespace NHibernate.Search.Mapping 9 | { 10 | public class ClassBridgeMapping 11 | { 12 | public ClassBridgeMapping(string name, IFieldBridge bridge) 13 | { 14 | this.Name = name; 15 | this.Bridge = bridge; 16 | 17 | this.Store = Attributes.Store.No; 18 | this.Index = Attributes.Index.Tokenized; 19 | } 20 | 21 | public string Name { get; private set; } 22 | public IFieldBridge Bridge { get; private set; } 23 | 24 | public float? Boost { get; set; } 25 | public Analyzer Analyzer { get; set; } 26 | public Attributes.Store Store { get; set; } 27 | public Index Index { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/NHibernate.Search/SearchException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace NHibernate.Search.Impl 5 | { 6 | [Serializable] 7 | public class SearchException : Exception 8 | { 9 | // 10 | // For guidelines regarding the creation of new exception types, see 11 | // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp 12 | // and 13 | // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp 14 | // 15 | 16 | public SearchException() { } 17 | public SearchException(string message) : base(message) { } 18 | public SearchException(string message, Exception inner) : base(message, inner) { } 19 | 20 | protected SearchException( 21 | SerializationInfo info, 22 | StreamingContext context) : base(info, context) { } 23 | } 24 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/FieldMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Lucene.Net.Analysis; 4 | using Lucene.Net.Analysis.Core; 5 | using NHibernate.Properties; 6 | using NHibernate.Search.Bridge; 7 | 8 | namespace NHibernate.Search.Mapping 9 | { 10 | public class FieldMapping : PropertyMappingBase 11 | { 12 | public FieldMapping(string name, IFieldBridge bridge, IGetter getter) : base(getter) 13 | { 14 | this.Name = name; 15 | this.Bridge = bridge; 16 | 17 | this.Store = Attributes.Store.No; 18 | this.Index = Attributes.Index.Tokenized; 19 | } 20 | 21 | public string Name { get; private set; } 22 | public IFieldBridge Bridge { get; private set; } 23 | public float? Boost { get; set; } 24 | public Attributes.Store Store { get; set; } 25 | public Attributes.Index Index { get; set; } 26 | public Analyzer Analyzer { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/TruncateStringBridge.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NHibernate.Search.Bridge; 3 | using NHibernate.Search.Bridge.Builtin; 4 | 5 | namespace NHibernate.Search.Tests.Bridge 6 | { 7 | public class TruncateStringBridge : StringBridge, IParameterizedBridge 8 | { 9 | private int div; 10 | 11 | #region IParameterizedBridge Members 12 | 13 | public void SetParameterValues(Dictionary parameters) 14 | { 15 | div = parameters["dividedBy"] == null ? 0 : (int)parameters["dividedBy"]; 16 | } 17 | 18 | #endregion 19 | 20 | public override object StringToObject(string stringValue) 21 | { 22 | return stringValue; 23 | } 24 | 25 | public override string ObjectToString(object obj) 26 | { 27 | string str = obj as string; 28 | return str != null ? str.Substring(0, str.Length / div) : null; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/Builtin/ValueTypeBridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NHibernate.Util; 3 | 4 | namespace NHibernate.Search.Bridge.Builtin 5 | { 6 | public class ValueTypeBridge : SimpleBridge 7 | where T : struct 8 | { 9 | #region Delegates 10 | 11 | public delegate T Parse(string str); 12 | 13 | #endregion 14 | 15 | public Parse parse = (Parse)Delegate.CreateDelegate(typeof(Parse), typeof(T) 16 | .GetMethod("Parse", 17 | new System.Type[] 18 | {typeof (string)})); 19 | 20 | public override Object StringToObject(String stringValue) 21 | { 22 | if (StringHelper.IsEmpty(stringValue)) return null; 23 | return parse(stringValue); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Filter/SecurityFilterFactory.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Index; 2 | using Lucene.Net.Search; 3 | using NHibernate.Search.Attributes; 4 | using NHibernate.Search.Filter; 5 | 6 | namespace NHibernate.Search.Tests.Filter 7 | { 8 | public class SecurityFilterFactory 9 | { 10 | private string login; 11 | 12 | [FilterParameter] 13 | public string Login 14 | { 15 | get { return login; } 16 | set { login = value; } 17 | } 18 | 19 | [Key] 20 | public FilterKey GetKey() 21 | { 22 | StandardFilterKey key = new StandardFilterKey(); 23 | key.AddParameter(login); 24 | return key; 25 | } 26 | 27 | [Factory] 28 | public Lucene.Net.Search.Filter GetFilter() 29 | { 30 | Lucene.Net.Search.Query query = new TermQuery(new Term("teacher", login)); 31 | return new CachingWrapperFilter(new QueryWrapperFilter(query)); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/AsyncWorkerTest.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Analysis.Core; 2 | using NHibernate.Cfg; 3 | using NUnit.Framework; 4 | 5 | namespace NHibernate.Search.Tests.Worker 6 | { 7 | [TestFixture] 8 | public class AsyncWorkerTest : WorkerTestCase 9 | { 10 | protected override void Configure(Configuration configuration) 11 | { 12 | base.Configure(configuration); 13 | configuration.SetProperty("hibernate.search.default.directory_provider", typeof(Store.RAMDirectoryProvider).AssemblyQualifiedName); 14 | configuration.SetProperty(Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName); 15 | configuration.SetProperty(Environment.WorkerScope, "transaction"); 16 | configuration.SetProperty(Environment.WorkerExecution, "async"); 17 | configuration.SetProperty(Environment.WorkerThreadPoolSize, "1"); 18 | configuration.SetProperty(Environment.WorkerThreadPoolSize, "10"); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Cfg/INHSConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Cfg 2 | { 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// Contract for configuration sources. 7 | /// 8 | public interface INHSConfiguration 9 | { 10 | /// 11 | /// Configured properties 12 | /// 13 | IDictionary Properties { get; } 14 | 15 | /// 16 | /// Gets SessionFactoryName. 17 | /// 18 | string SessionFactoryName { get; } 19 | 20 | /// 21 | /// If property exists in the dictionary, it returns the value. 22 | /// Otherwise, GetProperty will return null. 23 | /// 24 | /// 25 | /// The name of the property. 26 | /// 27 | /// 28 | /// The property value. 29 | /// 30 | string GetProperty(string name); 31 | } 32 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/IFullTextFilter.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search 2 | { 3 | /// 4 | /// Represents a full text filter that is about to be applied. 5 | /// Used to inject parameters 6 | /// 7 | public interface IFullTextFilter 8 | { 9 | /// 10 | /// Assigns a parameter to the filter. 11 | /// 12 | /// The .NET version differs from java, we do not locate setter methods, but find properties 13 | /// that have the FilterParameter attribute set. 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | IFullTextFilter SetParameter(string name, object value); 20 | 21 | /// 22 | /// Returns the value for a named parameter. 23 | /// 24 | /// 25 | /// 26 | object GetParameter(string name); 27 | } 28 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/FieldBridgeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NHibernate.Search.Mapping.Definition; 4 | 5 | namespace NHibernate.Search.Attributes 6 | { 7 | /// 8 | /// Specifies a given field bridge implementation 9 | /// 10 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 11 | public class FieldBridgeAttribute : Attribute, IFieldBridgeDefinition 12 | { 13 | private readonly System.Type impl; 14 | private readonly Dictionary parameters; 15 | 16 | public FieldBridgeAttribute(System.Type impl) 17 | { 18 | this.impl = impl; 19 | parameters = new Dictionary(); 20 | } 21 | 22 | public System.Type Impl 23 | { 24 | get { return impl; } 25 | } 26 | 27 | public Dictionary Parameters 28 | { 29 | get { return parameters; } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Engine/LoaderHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace NHibernate.Search.Engine 5 | { 6 | public abstract class LoaderHelper 7 | { 8 | private static readonly List objectNotFoundExceptions = new List(); 9 | 10 | static LoaderHelper() 11 | { 12 | objectNotFoundExceptions.Add(typeof(ObjectNotFoundException)); 13 | // TODO: Add NHibernate ObjectNotFoundException 14 | } 15 | 16 | public static bool IsObjectNotFoundException(Exception e) 17 | { 18 | bool objectNotFound = false; 19 | 20 | System.Type type = e.GetType(); 21 | foreach (System.Type clazz in objectNotFoundExceptions) 22 | { 23 | if (clazz.IsAssignableFrom(type)) 24 | { 25 | objectNotFound = true; 26 | break; 27 | } 28 | } 29 | 30 | return objectNotFound; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Optimizer/Worker.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Optimizer 4 | { 5 | [Indexed] 6 | public class Worker 7 | { 8 | [DocumentId] 9 | private int id; 10 | 11 | [Field(Index.Tokenized)] 12 | private string name; 13 | 14 | [Field(Index.UnTokenized)] 15 | private int workhours; 16 | 17 | public Worker() { } 18 | 19 | public Worker(string name, int workhours) 20 | { 21 | this.name = name; 22 | this.workhours = workhours; 23 | } 24 | 25 | public virtual int Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | public virtual string Name 32 | { 33 | get { return name; } 34 | set { name = value; } 35 | } 36 | 37 | public virtual int Workhours 38 | { 39 | get { return workhours; } 40 | set { workhours = value; } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/Contact.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Optimizer/Construction.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Optimizer 4 | { 5 | [Indexed] 6 | public class Construction 7 | { 8 | [DocumentId] 9 | private int id; 10 | 11 | [Field(Index.Tokenized)] 12 | private string name; 13 | 14 | [Field(Index.Tokenized)] 15 | private string address; 16 | 17 | public Construction() { } 18 | 19 | public Construction(string name, string address) 20 | { 21 | this.name = name; 22 | this.address = address; 23 | } 24 | 25 | public virtual int Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | public virtual string Name 32 | { 33 | get { return name; } 34 | set { name = value; } 35 | } 36 | 37 | public virtual string Address 38 | { 39 | get { return address; } 40 | set { address = value; } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/UnresolvedBridgeTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NHibernate.Cfg; 4 | using NHibernate.Search.Store; 5 | using NHibernate.Test; 6 | using NUnit.Framework; 7 | 8 | namespace NHibernate.Search.Tests.Bridge 9 | { 10 | [TestFixture] 11 | public class UnresolvedBridgeTest : SearchTestCase 12 | { 13 | protected override IEnumerable Mappings 14 | { 15 | get { return new string[] { }; } 16 | } 17 | 18 | [Test] 19 | public void SystemTypeForDocumentId() 20 | { 21 | Configuration tempCfg = new Configuration(); 22 | tempCfg.Configure(TestConfigurationHelper.GetDefaultConfigurationFilePath()); 23 | tempCfg.SetProperty("hibernate.search.default.directory_provider", typeof(RAMDirectoryProvider).AssemblyQualifiedName); 24 | tempCfg.AddClass(typeof(Gangster)); 25 | Assert.Throws(() => tempCfg.BuildSessionFactory(), "Unable to guess IFieldBridge for Id"); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/AttributeBased/AttributeSearchMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using NHibernate.Cfg; 5 | 6 | using NHibernate.Search.Attributes; 7 | 8 | namespace NHibernate.Search.Mapping.AttributeBased 9 | { 10 | using Type = System.Type; 11 | 12 | public class AttributeSearchMapping : ISearchMapping 13 | { 14 | public ICollection Build(Configuration cfg) 15 | { 16 | var indexedClasses = new List(); 17 | var builder = new AttributeSearchMappingBuilder(); 18 | 19 | foreach (var mapping in cfg.ClassMappings) 20 | { 21 | if (!this.IsIndexed(mapping.MappedClass)) 22 | continue; 23 | 24 | indexedClasses.Add(builder.Build(mapping.MappedClass)); 25 | } 26 | 27 | return indexedClasses; 28 | } 29 | 30 | private bool IsIndexed(Type type) 31 | { 32 | return AttributeUtil.HasAttribute(type); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/NHibernate.Search.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net461;net6.0 4 | 5 | 6 | 7 | 8 | Always 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/NHibernate.Search/NHibernate.Search.Lucene.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net461;netstandard2.0 4 | false 5 | NHibernate Search - Integration with Lucene.NET 6 | NHibernate Search brings the power of full text search engines to the persistence domain model by combining NHibernate with the capabilities of the Lucene.Net search engine. 7 | NHibernate.Search 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Query/Employee.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Query 2 | { 3 | using Attributes; 4 | 5 | [Indexed] 6 | public class Employee 7 | { 8 | private int id; 9 | private string lastname; 10 | private string dept; 11 | 12 | public Employee() 13 | { 14 | } 15 | 16 | public Employee(int id, string lastname, string dept) 17 | { 18 | this.id = id; 19 | this.lastname = lastname; 20 | this.dept = dept; 21 | } 22 | 23 | [DocumentId] 24 | public int Id 25 | { 26 | get { return id; } 27 | set { id = value; } 28 | } 29 | 30 | [Field(Index = Index.No, Store = Store.Yes)] 31 | public string Lastname 32 | { 33 | get { return lastname; } 34 | set { lastname = value; } 35 | } 36 | 37 | [Field(Index = Index.Tokenized, Store = Store.Yes)] 38 | public string Dept 39 | { 40 | get { return dept; } 41 | set { dept = value; } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/Cloud.hbm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Reader/Detective.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Reader 4 | { 5 | [Indexed] 6 | public class Detective 7 | { 8 | [DocumentId] 9 | private int id; 10 | 11 | [Field(Index.Tokenized)] 12 | private string name; 13 | 14 | [Field(Index.Tokenized)] 15 | private string physicalDescription; 16 | 17 | [Field(Index.UnTokenized)] 18 | private string badge; 19 | 20 | 21 | public virtual int Id 22 | { 23 | get { return id; } 24 | set { id = value; } 25 | } 26 | 27 | public virtual string Name 28 | { 29 | get { return name; } 30 | set { name = value; } 31 | } 32 | 33 | public virtual string PhysicalDescription 34 | { 35 | get { return physicalDescription; } 36 | set { physicalDescription = value; } 37 | } 38 | 39 | public virtual string Badge 40 | { 41 | get { return badge; } 42 | set { badge = value; } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Filter/IFilterCachingStrategy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NHibernate.Search.Filter 4 | { 5 | /// 6 | /// Defines the caching filter strategy 7 | /// 8 | public interface IFilterCachingStrategy 9 | { 10 | /// 11 | /// initialize the strategy from the properties 12 | /// The Properties must not be changed 13 | /// 14 | /// 15 | void Initialize(IDictionary properties); 16 | 17 | /// 18 | /// Retrieve the cached filter for a given key or null if not cached 19 | /// 20 | /// 21 | /// 22 | Lucene.Net.Search.Filter GetCachedFilter(FilterKey key); 23 | 24 | /// 25 | /// Propose a candidate filter for caching 26 | /// 27 | /// 28 | /// 29 | void AddCachedFilter(FilterKey key, Lucene.Net.Search.Filter filter); 30 | } 31 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Reader/IReaderProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Lucene.Net.Index; 3 | using NHibernate.Search.Engine; 4 | using NHibernate.Search.Store; 5 | 6 | namespace NHibernate.Search.Reader 7 | { 8 | /// 9 | /// Responsible for providing and managing the lifecycle of a read-only reader 10 | /// 11 | /// Note that the reader must be closed once opened. 12 | /// The ReaderProvider implementation must have a no-arg constructor 13 | /// 14 | /// 15 | public interface IReaderProvider 16 | { 17 | IndexReader OpenReader(IDirectoryProvider[] directoryProviders); 18 | 19 | void CloseReader(IndexReader reader); 20 | 21 | void Initialize(IDictionary properties, ISearchFactoryImplementor searchFactoryImplementor); 22 | 23 | /// 24 | /// Called when a is destroyed. This method typically releases resources. 25 | /// It is guaranteed to be executed after readers are released by queries (assuming no user error). 26 | /// 27 | void Destroy(); 28 | } 29 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Reader/Suspect.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Reader 4 | { 5 | [Indexed] 6 | public class Suspect 7 | { 8 | [DocumentId] 9 | private int id; 10 | 11 | [Field(Index.Tokenized)] 12 | private string name; 13 | 14 | [Field(Index.Tokenized)] 15 | private string physicalDescription; 16 | 17 | [Field(Index.Tokenized)] 18 | private string suspectCharge; 19 | 20 | 21 | public virtual int Id 22 | { 23 | get { return id; } 24 | set { id = value; } 25 | } 26 | 27 | public virtual string Name 28 | { 29 | get { return name; } 30 | set { name = value; } 31 | } 32 | 33 | public virtual string PhysicalDescription 34 | { 35 | get { return physicalDescription; } 36 | set { physicalDescription = value; } 37 | } 38 | 39 | public virtual string SuspectCharge 40 | { 41 | get { return suspectCharge; } 42 | set { suspectCharge = value; } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/ContainedInAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Describe the owning entity as being part of the target entity's 7 | /// index (to be more accurate, being part of the indexed object graph) 8 | /// 9 | /// Only necessary when an [Indexed] class is used as a 10 | /// target class. ContainedIn must mark the property pointing back 11 | /// to the IndexedEmbedded owning Entity 12 | /// 13 | /// Not necessary if the class is an Embeddable class. 14 | /// 15 | /// [Indexed] 16 | /// public class OrderLine 17 | /// { 18 | /// [IndexedEmbedded] 19 | /// private Order order; 20 | /// } 21 | /// 22 | /// [Indexed] 23 | /// public class Order 24 | /// { 25 | /// [ContainedIn] 26 | /// ISet lines; 27 | /// } 28 | /// 29 | /// 30 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] 31 | public class ContainedInAttribute : Attribute 32 | { 33 | } 34 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/TruncateFieldBridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lucene.Net.Documents; 3 | using NHibernate.Search.Bridge; 4 | using NHibernate.Util; 5 | 6 | namespace NHibernate.Search.Tests.Bridge 7 | { 8 | public class TruncateFieldBridge : IFieldBridge 9 | { 10 | #region IFieldBridge Members 11 | 12 | public void Set(string name, object value, Document document, FieldType fieldType, float? boost) 13 | { 14 | String indexedString = (String)value; 15 | //Do not add fields on empty strings, seems a sensible default in most situations 16 | if (StringHelper.IsNotEmpty(indexedString)) 17 | { 18 | Field field = new Field(name, indexedString.Substring(0, indexedString.Length / 2), fieldType); 19 | 20 | if (boost != null) field.Boost = boost.Value; 21 | document.Add(field); 22 | } 23 | } 24 | 25 | #endregion 26 | 27 | public Object Get(String name, Document document) 28 | { 29 | var field = document.GetField(name); 30 | return field.GetStringValue(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Async/DebugConnectionProvider.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using System; 12 | using System.Collections; 13 | using System.Collections.Generic; 14 | using System.Data; 15 | using System.Data.Common; 16 | using Iesi.Collections; 17 | using NHibernate.Connection; 18 | 19 | namespace NHibernate.Test 20 | { 21 | using System.Threading.Tasks; 22 | using System.Threading; 23 | public partial class DebugConnectionProvider : DriverConnectionProvider 24 | { 25 | 26 | public override async Task GetConnectionAsync(CancellationToken cancellationToken) 27 | { 28 | var connection = await (base.GetConnectionAsync(cancellationToken)); 29 | connections.Add(connection); 30 | return connection; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/SearchRestrictions.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Analysis.Standard; 2 | using Lucene.Net.QueryParsers.Classic; 3 | using NHibernate.Criterion; 4 | 5 | namespace NHibernate.Search 6 | { 7 | using System; 8 | 9 | [Obsolete("Use SetCriteriaQuery against IFullTextSession")] 10 | public static class SearchRestrictions 11 | { 12 | public static ICriterion Query(Lucene.Net.Search.Query luceneQuery) 13 | { 14 | return new LuceneQueryExpression(luceneQuery); 15 | } 16 | 17 | public static ICriterion Query(string luceneQuery) 18 | { 19 | QueryParser parser = new QueryParser(Lucene.Net.Util.LuceneVersion.LUCENE_48, string.Empty, new StandardAnalyzer(Lucene.Net.Util.LuceneVersion.LUCENE_48)); 20 | return Query(parser.Parse(luceneQuery)); 21 | } 22 | 23 | public static ICriterion Query(string defaultField, string luceneQuery) 24 | { 25 | QueryParser parser = new QueryParser(Lucene.Net.Util.LuceneVersion.LUCENE_48, defaultField, new StandardAnalyzer(Lucene.Net.Util.LuceneVersion.LUCENE_48)); 26 | return Query(parser.Parse(luceneQuery)); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/TwoWayString2FieldBridgeAdaptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lucene.Net.Documents; 3 | 4 | namespace NHibernate.Search.Bridge 5 | { 6 | /// 7 | /// Bridge to use a TwoWayStringBridge as a TwoWayFieldBridge 8 | /// 9 | public class TwoWayString2FieldBridgeAdaptor : String2FieldBridgeAdaptor, ITwoWayFieldBridge 10 | { 11 | private readonly ITwoWayStringBridge stringBridge; 12 | 13 | public TwoWayString2FieldBridgeAdaptor(ITwoWayStringBridge stringBridge) : base(stringBridge) 14 | { 15 | this.stringBridge = stringBridge; 16 | } 17 | 18 | #region ITwoWayFieldBridge Members 19 | 20 | public object Get(string name, Document document) 21 | { 22 | var field = document.GetField(name); 23 | if (field == null) 24 | { 25 | return null; 26 | } 27 | 28 | return stringBridge.StringToObject(field.GetStringValue()); 29 | } 30 | 31 | public string ObjectToString(object obj) 32 | { 33 | return stringBridge.ObjectToString(obj); 34 | } 35 | 36 | #endregion 37 | } 38 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/DirectoryProvider/SnowStorm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Tests.DirectoryProvider 4 | { 5 | using Attributes; 6 | 7 | [Indexed] 8 | public class SnowStorm 9 | { 10 | private DateTime dateTime; 11 | private long id; 12 | private string location; 13 | 14 | /// 15 | /// Gets or sets Id. 16 | /// 17 | [DocumentId] 18 | public virtual long Id 19 | { 20 | get { return id; } 21 | set { id = value; } 22 | } 23 | 24 | /// 25 | /// Gets or sets DateTime. 26 | /// 27 | [Field(Index.UnTokenized)] 28 | [DateBridge(Resolution.Day)] 29 | public virtual DateTime DateTime 30 | { 31 | get { return dateTime; } 32 | set { dateTime = value; } 33 | } 34 | 35 | /// 36 | /// Gets or sets Location. 37 | /// 38 | [Field(Index.Tokenized)] 39 | public virtual string Location 40 | { 41 | get { return location; } 42 | set { location = value; } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Query/FullTextFilterImpl.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Query 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class FullTextFilterImpl : IFullTextFilter 6 | { 7 | private readonly Dictionary parameters = new Dictionary(); 8 | private string name; 9 | 10 | /// 11 | /// Gets or sets the name of the filter. 12 | /// 13 | public string Name 14 | { 15 | get { return name; } 16 | set { name = value; } 17 | } 18 | 19 | /// 20 | /// Gets the collection of parameters 21 | /// 22 | public Dictionary Parameters 23 | { 24 | get { return parameters; } 25 | } 26 | 27 | #region IFullTextFilter Members 28 | 29 | public IFullTextFilter SetParameter(string name, object value) 30 | { 31 | parameters[name] = value; 32 | 33 | return this; 34 | } 35 | 36 | public object GetParameter(string name) 37 | { 38 | return parameters[name]; 39 | } 40 | 41 | #endregion 42 | } 43 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Engine/EntityInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NHibernate.Search.Engine 4 | { 5 | public class EntityInfo 6 | { 7 | private System.Type clazz; 8 | private object id; 9 | private object[] projection; 10 | private List indexesOfThis; 11 | 12 | /// 13 | /// 14 | /// 15 | public System.Type Clazz 16 | { 17 | get { return clazz; } 18 | set { clazz = value; } 19 | } 20 | 21 | /// 22 | /// 23 | /// 24 | public object Id 25 | { 26 | get { return id; } 27 | set { id = value; } 28 | } 29 | 30 | /// 31 | /// 32 | /// 33 | public object[] Projection 34 | { 35 | get { return projection; } 36 | set { projection = value; } 37 | } 38 | 39 | /// 40 | /// 41 | /// 42 | public List IndexesOfThis 43 | { 44 | get { return indexesOfThis; } 45 | set { indexesOfThis = value; } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /.github/workflows/GenerateAsyncCode.yml: -------------------------------------------------------------------------------- 1 | name: Generate Async code 2 | 3 | on: 4 | pull_request_target: 5 | paths: 6 | - '**.cs' 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | generate-async: 13 | runs-on: ubuntu-latest 14 | 15 | env: 16 | IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | with: 21 | fetch-depth: 0 22 | ref: ${{ github.event.pull_request.head.ref }} 23 | repository: ${{ github.event.pull_request.head.repo.full_name }} 24 | 25 | - name: Setup .NET 26 | uses: actions/setup-dotnet@v4 27 | with: 28 | dotnet-version: 6.0.x 29 | 30 | - name: Generate Async code 31 | run: | 32 | dotnet tool restore 33 | dotnet restore src 34 | dotnet async-generator 35 | 36 | - name: Push changes 37 | run: | 38 | git config user.name github-actions[bot] 39 | git config user.email github-actions[bot]@users.noreply.github.com 40 | if [[ -z "$(git status --porcelain)" ]]; then 41 | echo "No changes to commit" 42 | exit 0 43 | fi 44 | git add -A 45 | git commit -am "Generate async files" 46 | git push 47 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Product.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Iesi.Collections.Generic; 3 | using NHibernate.Search.Attributes; 4 | 5 | 6 | namespace NHibernate.Search.Tests.Embedded 7 | { 8 | [Indexed] 9 | public class Product 10 | { 11 | [DocumentId] 12 | private int id; 13 | [Field(Index.Tokenized)] 14 | private string name; 15 | [IndexedEmbedded] 16 | private ISet authors = new HashSet(); 17 | //[IndexedEmbedded] 18 | private IDictionary orders = new Dictionary(); 19 | 20 | public virtual int Id 21 | { 22 | get { return id; } 23 | set { id = value; } 24 | } 25 | 26 | public virtual string Name 27 | { 28 | get { return name; } 29 | set { name = value; } 30 | } 31 | 32 | public virtual ISet Authors 33 | { 34 | get { return authors; } 35 | set { authors = value; } 36 | } 37 | 38 | public virtual IDictionary Orders 39 | { 40 | get { return orders; } 41 | set { orders = value; } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/Email.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Session 4 | { 5 | [Indexed] 6 | public class Email 7 | { 8 | private string body; 9 | private string header; 10 | private int id; 11 | private string title; 12 | 13 | public Email() { } 14 | 15 | public Email(int id, string title, string body) 16 | { 17 | this.id = id; 18 | this.title = title; 19 | this.body = body; 20 | } 21 | 22 | [DocumentId] 23 | public virtual int Id 24 | { 25 | get { return id; } 26 | set { id = value; } 27 | } 28 | 29 | [Field(Index.Tokenized)] 30 | public virtual string Title 31 | { 32 | get { return title; } 33 | set { title = value; } 34 | } 35 | 36 | [Field(Index.Tokenized)] 37 | public virtual string Body 38 | { 39 | get { return body; } 40 | set { body = value; } 41 | } 42 | 43 | public virtual string Header 44 | { 45 | get { return header; } 46 | set { header = value; } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Store/IDirectoryProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Lucene.Net.Store; 3 | using NHibernate.Search.Engine; 4 | 5 | namespace NHibernate.Search.Store 6 | { 7 | public interface IDirectoryProvider 8 | { 9 | /// 10 | /// Returns an initialized Lucene Directory. This method call must be threadsafe 11 | /// 12 | Directory Directory { get; } 13 | 14 | /// 15 | /// get the information to initialize the directory and build its hashCode/equals method 16 | /// 17 | /// 18 | /// 19 | /// 20 | void Initialize(string directoryProviderName, IDictionary indexProps, ISearchFactoryImplementor searchFactory); 21 | 22 | /// 23 | /// Executed after initialize, this method set up the heavy process of starting up the DirectoryProvider 24 | /// IO processing as well as backgroup processing are expected to be set up here 25 | /// 26 | /// TODO stop() method, for now use finalize() 27 | void Start(); 28 | } 29 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Mapping/SearchMappingFactoryTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using NHibernate.Cfg; 5 | using NHibernate.Search.Mapping; 6 | using NHibernate.Search.Mapping.AttributeBased; 7 | using NUnit.Framework; 8 | 9 | namespace NHibernate.Search.Tests.Mapping 10 | { 11 | [TestFixture] 12 | public class SearchMappingFactoryTest 13 | { 14 | private class TestSearchMapping : ISearchMapping 15 | { 16 | public ICollection Build(Configuration cfg) 17 | { 18 | throw new NotSupportedException(); 19 | } 20 | } 21 | 22 | [Test] 23 | public void TestCreateCreatesAttributeMappingByDefault() 24 | { 25 | Assert.IsInstanceOf(SearchMappingFactory.CreateMapping(new Configuration())); 26 | } 27 | 28 | [Test] 29 | public void TestCreateCreatesConfiguredMapping() 30 | { 31 | var cfg = new Configuration(); 32 | cfg.SetProperty("hibernate.search.mapping", typeof(TestSearchMapping).AssemblyQualifiedName); 33 | 34 | Assert.IsInstanceOf(SearchMappingFactory.CreateMapping(cfg)); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/PaddedIntegerBridge.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Bridge 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using NHibernate.Search.Bridge; 7 | 8 | public class PaddedIntegerBridge : ITwoWayStringBridge, IParameterizedBridge 9 | { 10 | public static string PADDING_PROPERTY = "padding"; 11 | 12 | private int padding = 5; // default; 13 | 14 | public void SetParameterValues(Dictionary parameters) 15 | { 16 | object value; 17 | if (parameters.TryGetValue(PADDING_PROPERTY, out value)) 18 | { 19 | this.padding = (int)value; 20 | } 21 | } 22 | 23 | public string ObjectToString(object obj) 24 | { 25 | int value = (int)obj; 26 | string rawInteger = value.ToString(); 27 | if (rawInteger.Length > padding) 28 | { 29 | throw new ArgumentOutOfRangeException("obj", "Try to pad on a number too big"); 30 | } 31 | 32 | return value.ToString("D" + padding); 33 | } 34 | 35 | public object StringToObject(string value) 36 | { 37 | return int.Parse(value); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/ITwoWayFieldBridge.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Documents; 2 | 3 | namespace NHibernate.Search.Bridge 4 | { 5 | /// 6 | /// An IFieldBridge able to convert the index representation back into an object without losing information 7 | /// 8 | /// Any bridge expected to process a document id should implement this interface 9 | /// EXPERIMENTAL Consider this interface as private 10 | /// 11 | /// TODO: rework the interface inheritance there are some common concepts with StringBridge 12 | public interface ITwoWayFieldBridge : IFieldBridge 13 | { 14 | /// 15 | /// Build the element object from the Document 16 | /// 17 | /// 18 | /// 19 | /// The return value is the Entity id 20 | object Get(string value, Document document); 21 | 22 | /// 23 | /// Convert the object representation to a String 24 | /// The return String must not be null, it can be empty though 25 | /// EXPERIMENTAL API subject to change in the future 26 | /// 27 | /// 28 | /// 29 | string ObjectToString(object obj); 30 | } 31 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/DocumentIdMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NHibernate.Mapping; 4 | using NHibernate.Properties; 5 | using NHibernate.Search.Bridge; 6 | 7 | namespace NHibernate.Search.Mapping 8 | { 9 | public class DocumentIdMapping : PropertyMappingBase 10 | { 11 | public const string DefaultIndexedName = "id"; 12 | 13 | public DocumentIdMapping(ITwoWayFieldBridge bridge, IGetter getter) 14 | : this(DefaultIndexedName, RootClass.DefaultIdentifierColumnName, bridge, getter) 15 | { 16 | } 17 | 18 | public DocumentIdMapping(string name, ITwoWayFieldBridge bridge, IGetter getter) 19 | : this(name, RootClass.DefaultIdentifierColumnName, bridge, getter) 20 | { 21 | } 22 | 23 | public DocumentIdMapping(string name, string propertyName, ITwoWayFieldBridge bridge, IGetter getter) : base(getter) 24 | { 25 | this.Name = name; 26 | this.PropertyName = propertyName; 27 | this.Bridge = bridge; 28 | } 29 | 30 | public string Name { get; private set; } 31 | public string PropertyName { get; private set; } 32 | public ITwoWayFieldBridge Bridge { get; private set; } 33 | 34 | public float? Boost { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Reader/ReaderProviderHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lucene.Net.Index; 3 | using NHibernate.Search.Impl; 4 | 5 | namespace NHibernate.Search.Reader 6 | { 7 | /// 8 | /// 9 | /// 10 | public static class ReaderProviderHelper 11 | { 12 | public static IndexReader BuildMultiReader(int length, IndexReader[] readers) 13 | { 14 | if (length == 0) 15 | return null; 16 | 17 | try 18 | { 19 | // NB Everything should be the same so wrap in a CacheableMultiReader even if there's only one. 20 | return new CacheableMultiReader(readers); 21 | } 22 | catch (Exception e) 23 | { 24 | Clean(readers); 25 | throw new SearchException("Unable to open a MultiReader", e); 26 | } 27 | } 28 | 29 | public static void Clean(params IndexReader[] readers) 30 | { 31 | foreach (IndexReader reader in readers) 32 | { 33 | try 34 | { 35 | reader.Dispose(); 36 | } 37 | catch (Exception) 38 | { 39 | // Swallow 40 | } 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Store/NotShardedStrategy.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Documents; 2 | 3 | namespace NHibernate.Search.Store 4 | { 5 | public class NotShardedStrategy : IIndexShardingStrategy 6 | { 7 | private IDirectoryProvider[] directoryProvider; 8 | 9 | #region IIndexShardingStrategy Members 10 | 11 | public void Initialize(object properties, IDirectoryProvider[] providers) 12 | { 13 | directoryProvider = providers; 14 | if (providers.GetUpperBound(0) > 1) 15 | { 16 | throw new AssertionFailure("Using SingleDirectoryProviderSelectionStrategy with multiple DirectoryProviders"); 17 | } 18 | } 19 | 20 | public IDirectoryProvider[] GetDirectoryProvidersForAllShards() 21 | { 22 | return directoryProvider; 23 | } 24 | 25 | public IDirectoryProvider GetDirectoryProviderForAddition(System.Type entity, object id, string idInString, 26 | Document document) 27 | { 28 | return directoryProvider[0]; 29 | } 30 | 31 | public IDirectoryProvider[] GetDirectoryProvidersForDeletion(System.Type entity, object id, string idInString) 32 | { 33 | return directoryProvider; 34 | } 35 | 36 | #endregion 37 | } 38 | } -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | env: 11 | IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 0 17 | 18 | - name: Setup .NET 19 | uses: actions/setup-dotnet@v4 20 | with: 21 | dotnet-version: 6.0.x 22 | 23 | - name: Restore dependencies 24 | run: dotnet restore src 25 | 26 | - name: Build 27 | run: dotnet build src -m:1 --no-restore 28 | 29 | - name: Configure 30 | run: cp build-common/teamcity-hibernate.cfg.xml ./hibernate.cfg.xml 31 | 32 | - name: Test 33 | run: dotnet test src -f net6.0 --no-build --collect:"XPlat Code Coverage" --results-directory ./coverage 34 | 35 | - name: Code Coverage Report 36 | uses: irongut/CodeCoverageSummary@v1.3.0 37 | with: 38 | filename: coverage/**/coverage.cobertura.xml 39 | badge: true 40 | fail_below_min: true 41 | format: markdown 42 | output: both 43 | thresholds: '60 80' 44 | 45 | - name: Add Coverage PR Comment 46 | uses: marocchino/sticky-pull-request-comment@v2 47 | if: github.event_name == 'pull_request' 48 | with: 49 | recreate: true 50 | path: code-coverage-results.md 51 | -------------------------------------------------------------------------------- /NHibernate.Search.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NHibernate.Search 5 | NHibernate Search 6 | 2.1.0.1000 7 | NHibernate Community 8 | Dario Quintana 9 | http://www.gnu.org/licenses/lgpl.html 10 | http://nhforge.org 11 | http://darioquintana.com.ar/files/nhsearch-logo.png 12 | false 13 | 14 | NHibernate Search brings the power of full text search engines to the persistence domain model by combining NHibernate with the capabilities of the Lucene.Net search engine. 15 | 16 | 17 | NHibernate Search brings the power of full text search engines to the persistence domain model by combining NHibernate with the capabilities of the Lucene.Net search engine. 18 | 19 | NHibernate Search Lucene FullText Text 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/Work.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using NHibernate.Properties; 4 | 5 | namespace NHibernate.Search.Backend 6 | { 7 | /// 8 | /// work unit. Only make sense inside the same session since it uses the scope principle 9 | /// 10 | public class Work 11 | { 12 | private readonly object entity; 13 | private readonly object id; 14 | private readonly IGetter idGetter; 15 | private readonly WorkType workType; 16 | 17 | public Work(object entity, Object id, WorkType type) 18 | { 19 | this.entity = entity; 20 | this.id = id; 21 | workType = type; 22 | } 23 | 24 | public Work(object entity, IGetter idGetter, WorkType type) 25 | { 26 | this.entity = entity; 27 | this.idGetter = idGetter; 28 | workType = type; 29 | } 30 | 31 | public object Entity 32 | { 33 | get { return entity; } 34 | } 35 | 36 | public object Id 37 | { 38 | get { return id; } 39 | } 40 | 41 | public IGetter IdGetter 42 | { 43 | get { return idGetter; } 44 | } 45 | 46 | public WorkType WorkType 47 | { 48 | get { return workType; } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Async/Worker/SyncWorkerTest.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using Lucene.Net.Analysis.Core; 12 | using NHibernate.Cfg; 13 | using NUnit.Framework; 14 | 15 | namespace NHibernate.Search.Tests.Worker 16 | { 17 | using System.Threading.Tasks; 18 | [TestFixture] 19 | public class SyncWorkerTestAsync : WorkerTestCaseAsync 20 | { 21 | protected override void Configure(Configuration configuration) 22 | { 23 | base.Configure(configuration); 24 | configuration.SetProperty("hibernate.search.default.directory_provider", typeof(Store.RAMDirectoryProvider).AssemblyQualifiedName); 25 | configuration.SetProperty(Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName); 26 | configuration.SetProperty(Environment.WorkerScope, "transaction"); 27 | configuration.SetProperty(Environment.WorkerExecution, "sync"); // Note: It is WorkerPrefix in the Java version, but it must be a typo 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Bridge/String2FieldBridgeAdaptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lucene.Net.Documents; 3 | using NHibernate.Util; 4 | 5 | namespace NHibernate.Search.Bridge 6 | { 7 | /// 8 | /// Bridge to use a StringBridge as a FieldBridge 9 | /// 10 | public class String2FieldBridgeAdaptor : IFieldBridge 11 | { 12 | private readonly IStringBridge stringBridge; 13 | 14 | public String2FieldBridgeAdaptor(IStringBridge stringBridge) 15 | { 16 | this.stringBridge = stringBridge; 17 | } 18 | 19 | #region IFieldBridge Members 20 | 21 | public void Set(string name, object value, Document document, FieldType fieldType, float? boost) 22 | { 23 | string indexedString = stringBridge.ObjectToString(value); 24 | 25 | // Do not add fields on empty strings, seems a sensible default in most situations 26 | // TODO if Store, probably also save empty ones 27 | if (StringHelper.IsNotEmpty(indexedString)) 28 | { 29 | Field field = new Field(name, indexedString, fieldType); 30 | if (boost != null) 31 | { 32 | field.Boost = boost.Value; 33 | } 34 | 35 | document.Add(field); 36 | } 37 | } 38 | 39 | #endregion 40 | } 41 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/ProjectionConstants.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search 2 | { 3 | public static class ProjectionConstants 4 | { 5 | /// 6 | /// Represents the Hibernate Entity returned in a search. 7 | /// 8 | public const string THIS = "__HSearch_This"; 9 | 10 | /// 11 | /// The Lucene document returned by a search. 12 | /// 13 | public const string DOCUMENT = "__HSearch_Document"; 14 | 15 | /// 16 | /// The legacy document's score from a search. 17 | /// 18 | public const string SCORE = "__HSearch_Score"; 19 | 20 | /// 21 | /// The boost value of the Lucene document. 22 | /// 23 | public const string BOOST = "__HSearch_Boost"; 24 | 25 | /// 26 | /// Object id property 27 | /// 28 | public const string ID = "__HSearch_id"; 29 | 30 | /// 31 | /// Lucene Document id 32 | /// 33 | /// 34 | /// Experimental: If you use this feature, please speak up in the forum 35 | /// Expert: Lucene document id can change overtime between 2 different IndexReader opening. 36 | /// 37 | public const string DOCUMENT_ID = "__HSearch_DocumentId"; 38 | } 39 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/FieldAccess/Document.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.FieldAccess 4 | { 5 | [Indexed(Index = "DocumentField")] 6 | public class Document 7 | { 8 | [DocumentId] private int id; 9 | 10 | [Field(Index.Tokenized, Name = "Abstract", Store = Attributes.Store.No)] private string summary; 11 | 12 | [Field(Index.Tokenized, Store = Attributes.Store.No)] private string text; 13 | 14 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)][Boost(2)] private string title; 15 | 16 | public Document() { } 17 | 18 | public Document(string title, string summary, string text) 19 | { 20 | this.title = title; 21 | this.summary = summary; 22 | this.text = text; 23 | } 24 | 25 | public virtual int Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | public virtual string Title 32 | { 33 | get { return title; } 34 | set { title = value; } 35 | } 36 | 37 | public virtual string Summary 38 | { 39 | get { return summary; } 40 | set { summary = value; } 41 | } 42 | 43 | public virtual string Text 44 | { 45 | get { return text; } 46 | set { text = value; } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Reader/CacheableMultiReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Lucene.Net.Index; 3 | using Lucene.Net.Search; 4 | 5 | namespace NHibernate.Search.Reader 6 | { 7 | /// 8 | /// MultiReader ensuring equals returns true if the underlying readers are the same (and in the same order) 9 | /// Especially useful when using 10 | /// 11 | public class CacheableMultiReader : MultiReader 12 | { 13 | private readonly IndexReader[] subReaders; 14 | 15 | public CacheableMultiReader(IndexReader[] subReaders) : base(subReaders) 16 | { 17 | this.subReaders = subReaders; 18 | } 19 | 20 | private bool BusinessEquals(CacheableMultiReader other) 21 | { 22 | if (other == null) return false; 23 | 24 | int length = subReaders.Length; 25 | if (length != other.subReaders.Length) return false; 26 | for (int index = 0; index < length; index++) 27 | if (!subReaders[index].Equals(other.subReaders[index])) 28 | return false; 29 | 30 | return true; 31 | } 32 | 33 | public bool Equals(CacheableMultiReader obj) 34 | { 35 | // NB We need to cast down to obj to get the simple "==" 36 | if (obj == null) return false; 37 | 38 | return BusinessEquals(obj); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/LuceneWorker/Document.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.LuceneWorkerFixture 4 | { 5 | [Indexed(Index = "DocumentField")] 6 | public class Document 7 | { 8 | [DocumentId] private int id; 9 | 10 | [Field(Index.Tokenized, Name = "Abstract", Store = Attributes.Store.No)] private string summary; 11 | 12 | [Field(Index.Tokenized, Store = Attributes.Store.No)] private string text; 13 | 14 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)][Boost(2)] private string title; 15 | 16 | public Document() { } 17 | 18 | public Document(string title, string summary, string text) 19 | { 20 | this.title = title; 21 | this.summary = summary; 22 | this.text = text; 23 | } 24 | 25 | public virtual int Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | public virtual string Title 32 | { 33 | get { return title; } 34 | set { title = value; } 35 | } 36 | 37 | public virtual string Summary 38 | { 39 | get { return summary; } 40 | set { summary = value; } 41 | } 42 | 43 | public virtual string Text 44 | { 45 | get { return text; } 46 | set { text = value; } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/DocumentTop.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests 4 | { 5 | [Indexed(Index = "Documents")] 6 | public class DocumentTop 7 | { 8 | private int id; 9 | private string title; 10 | private string summary; 11 | private string text; 12 | 13 | public DocumentTop() { } 14 | 15 | public DocumentTop(string title, string summary, string text) 16 | { 17 | this.title = title; 18 | this.summary = summary; 19 | this.text = text; 20 | } 21 | 22 | [DocumentId] 23 | public virtual int Id 24 | { 25 | get { return id; } 26 | set { id = value; } 27 | } 28 | 29 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)] 30 | [Boost(2)] 31 | public virtual string Title 32 | { 33 | get { return title; } 34 | set { title = value; } 35 | } 36 | 37 | [Field(Index.Tokenized, Name = "Abstract", Store = Attributes.Store.No)] 38 | public virtual string Summary 39 | { 40 | get { return summary; } 41 | set { summary = value; } 42 | } 43 | 44 | [Field(Index.Tokenized, Store = Attributes.Store.No)] 45 | public virtual string Text 46 | { 47 | get { return text; } 48 | set { text = value; } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/LuceneIndexingParameters.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Backend 2 | { 3 | /// 4 | /// Wrapper class around the Lucene indexing parameters mergeFactor, maxMergeDocs and 5 | /// maxBufferedDocs. 6 | ///

7 | /// There are two sets of these parameters. One is for regular indexing the other is for batch indexing 8 | /// triggered by FullTextSessoin.Index(Object entity) 9 | ///

10 | public class LuceneIndexingParameters 11 | { 12 | private readonly ParameterSet batchIndexParameters; 13 | private readonly ParameterSet transactionIndexParameters; 14 | 15 | #region Constructors 16 | 17 | /// 18 | /// Constructor which instantiates a new parameter object with the the default values. 19 | /// 20 | public LuceneIndexingParameters() 21 | { 22 | batchIndexParameters = new ParameterSet(); 23 | transactionIndexParameters = new ParameterSet(); 24 | } 25 | 26 | #endregion 27 | 28 | #region Property methods 29 | 30 | public ParameterSet BatchIndexParameters 31 | { 32 | get { return batchIndexParameters; } 33 | } 34 | 35 | public ParameterSet TransactionIndexParameters 36 | { 37 | get { return transactionIndexParameters; } 38 | } 39 | 40 | #endregion 41 | } 42 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Filter/MruFilterCachingStrategy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NHibernate.Util; 4 | 5 | namespace NHibernate.Search.Filter 6 | { 7 | public class MruFilterCachingStrategy : IFilterCachingStrategy 8 | { 9 | private const string SIZE = Environment.FilterCachingStrategy + ".size"; 10 | private SoftLimitMRUCache cache; 11 | 12 | #region IFilterCachingStrategy Members 13 | 14 | public void Initialize(IDictionary properties) 15 | { 16 | int size = 128; 17 | if (properties.ContainsKey(SIZE)) 18 | { 19 | if (!int.TryParse(properties[SIZE], out size)) 20 | { 21 | // TODO: Log a warning 22 | size = 128; 23 | } 24 | } 25 | 26 | cache = new SoftLimitMRUCache(size); 27 | } 28 | 29 | public Lucene.Net.Search.Filter GetCachedFilter(FilterKey key) 30 | { 31 | try 32 | { 33 | return (Lucene.Net.Search.Filter)cache[key]; 34 | } 35 | catch (NullReferenceException) 36 | { 37 | return null; 38 | } 39 | } 40 | 41 | public void AddCachedFilter(FilterKey key, Lucene.Net.Search.Filter filter) 42 | { 43 | cache.Put(key, filter); 44 | } 45 | 46 | #endregion 47 | } 48 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Async/Worker/AsyncWorkerTest.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using Lucene.Net.Analysis.Core; 12 | using NHibernate.Cfg; 13 | using NUnit.Framework; 14 | 15 | namespace NHibernate.Search.Tests.Worker 16 | { 17 | using System.Threading.Tasks; 18 | [TestFixture] 19 | public class AsyncWorkerTestAsync : WorkerTestCaseAsync 20 | { 21 | protected override void Configure(Configuration configuration) 22 | { 23 | base.Configure(configuration); 24 | configuration.SetProperty("hibernate.search.default.directory_provider", typeof(Store.RAMDirectoryProvider).AssemblyQualifiedName); 25 | configuration.SetProperty(Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName); 26 | configuration.SetProperty(Environment.WorkerScope, "transaction"); 27 | configuration.SetProperty(Environment.WorkerExecution, "async"); 28 | configuration.SetProperty(Environment.WorkerThreadPoolSize, "1"); 29 | configuration.SetProperty(Environment.WorkerThreadPoolSize, "10"); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/Address.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Iesi.Collections.Generic; 3 | using NHibernate.Search.Attributes; 4 | 5 | namespace NHibernate.Search.Tests.Embedded 6 | { 7 | [Indexed] 8 | public class Address 9 | { 10 | [IndexedEmbedded] 11 | private Country country; 12 | 13 | [DocumentId] 14 | private long id; 15 | 16 | [IndexedEmbedded(Depth = 1, Prefix = "ownedBy_", TargetElement = typeof(Owner))] 17 | private Owner ownedBy; 18 | 19 | [Field(Index.Tokenized)] 20 | private string street; 21 | 22 | [ContainedIn] 23 | private ISet towers = new HashSet(); 24 | 25 | public virtual long Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | public virtual string Street 32 | { 33 | get { return street; } 34 | set { street = value; } 35 | } 36 | 37 | public virtual Owner OwnedBy 38 | { 39 | get { return ownedBy; } 40 | set { ownedBy = value; } 41 | } 42 | 43 | public virtual ISet Towers 44 | { 45 | get { return towers; } 46 | set { towers = value; } 47 | } 48 | 49 | public virtual Country Country 50 | { 51 | get { return country; } 52 | set { country = value; } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Mapping/DocumentMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Lucene.Net.Analysis; 4 | using NHibernate.Search.Engine; 5 | 6 | using Lucene.Net.Analysis.Core; 7 | 8 | namespace NHibernate.Search.Mapping 9 | { 10 | using Type = System.Type; 11 | 12 | public class DocumentMapping 13 | { 14 | public DocumentMapping(Type mappedClass) 15 | { 16 | this.MappedClass = mappedClass; 17 | 18 | this.ClassBridges = new List(); 19 | this.Fields = new List(); 20 | this.Embedded = new List(); 21 | this.ContainedIn = new List(); 22 | this.FullTextFilterDefinitions = new List(); 23 | } 24 | 25 | public Type MappedClass { get; private set; } 26 | public string IndexName { get; set; } 27 | public float? Boost { get; set; } 28 | public Analyzer Analyzer { get; set; } 29 | 30 | public IList ClassBridges { get; private set; } 31 | 32 | public DocumentIdMapping DocumentId { get; set; } 33 | public IList Fields { get; private set; } 34 | public IList Embedded { get; private set; } 35 | 36 | public IList FullTextFilterDefinitions { get; private set; } 37 | 38 | public IList ContainedIn { get; private set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/BridgeParameterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Parameter (basically key/value pattern) 7 | /// 8 | [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] 9 | public class ParameterAttribute : Attribute 10 | { 11 | private readonly string name; 12 | private readonly object value; 13 | private string owner; 14 | 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 20 | /// Parameter names are capitalized so they appear nice in Intellisense 21 | public ParameterAttribute(string Name, object Value) 22 | { 23 | this.name = Name; 24 | this.value = Value; 25 | } 26 | 27 | /// 28 | /// 29 | /// 30 | public string Name 31 | { 32 | get { return name; } 33 | } 34 | 35 | /// 36 | /// 37 | /// 38 | public object Value 39 | { 40 | get { return value; } 41 | } 42 | 43 | /// 44 | /// The bridge that owns this parameter 45 | /// 46 | public string Owner 47 | { 48 | get { return owner; } 49 | set { owner = value; } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/DateSplitBridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Tests.Bridge 4 | { 5 | using Lucene.Net.Documents; 6 | 7 | using NHibernate.Search.Bridge; 8 | 9 | public class DateSplitBridge : IFieldBridge 10 | { 11 | public void Set(string name, object value, Document document, FieldType fieldType, float? boost) 12 | { 13 | DateTime date = (DateTime)value; 14 | 15 | int year = date.Year; 16 | int month = date.Month; 17 | int day = date.Day; 18 | 19 | // set year 20 | Field field = new Field(name + ".year", year.ToString(), fieldType); 21 | if (boost != null) 22 | { 23 | field.Boost = boost.Value; 24 | } 25 | document.Add(field); 26 | 27 | // set month and pad it if necessary 28 | field = new Field(name + ".month", month.ToString("D2"), fieldType); 29 | if (boost != null) 30 | { 31 | field.Boost = boost.Value; 32 | } 33 | document.Add(field); 34 | 35 | // set day and pad it if necessary 36 | field = new Field(name + ".day", day.ToString("D2"), fieldType); 37 | if (boost != null) 38 | { 39 | field.Boost = boost.Value; 40 | } 41 | document.Add(field); 42 | 43 | throw new NotImplementedException(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/MyEntity.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests.Analyzer 4 | { 5 | [Indexed] 6 | [Analyzer(typeof(Test1Analyzer))] 7 | public class MyEntity 8 | { 9 | [DocumentId] 10 | private int id; 11 | 12 | [Field(Index.Tokenized)] 13 | private string entity; 14 | 15 | [Field(Index.Tokenized)] 16 | [Analyzer(typeof(Test2Analyzer))] 17 | private string property; 18 | 19 | [Field(Index.Tokenized, Analyzer = typeof(Test3Analyzer))] 20 | [Analyzer(typeof(Test2Analyzer))] 21 | private string field; 22 | 23 | [IndexedEmbedded] 24 | private MyComponent component; 25 | 26 | public virtual int Id 27 | { 28 | get { return id; } 29 | set { id = value; } 30 | } 31 | 32 | public virtual string Entity 33 | { 34 | get { return entity; } 35 | set { entity = value; } 36 | } 37 | 38 | public virtual string Property 39 | { 40 | get { return property; } 41 | set { property = value; } 42 | } 43 | 44 | public virtual string Field 45 | { 46 | get { return field; } 47 | set { field = value; } 48 | } 49 | 50 | public virtual MyComponent Component 51 | { 52 | get { return component; } 53 | set { component = value; } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/Index.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Attributes 2 | { 3 | /// 4 | /// Defines how an Field should be indexed 5 | /// 6 | public enum Index 7 | { 8 | /// 9 | /// Do not index the field value. This field can thus not be searched, 10 | /// but one can still access its contents provided it is {@link Store stored}. 11 | /// 12 | No, 13 | /// 14 | /// Index the field's value so it can be searched. An Analyzer will be used 15 | /// to tokenize and possibly further normalize the text before its 16 | /// terms will be stored in the index. This is useful for common text. 17 | /// 18 | Tokenized, 19 | /// 20 | /// Index the field's value without using an Analyzer, so it can be searched. 21 | /// As no analyzer is used the value will be stored as a single term. This is 22 | /// useful for unique Ids like product numbers. 23 | /// 24 | UnTokenized, 25 | /// 26 | /// Index the field's value without an Analyzer, and disable 27 | /// the storing of norms. No norms means that index-time boosting 28 | /// and field length normalization will be disabled. The benefit is 29 | /// less memory usage as norms take up one byte per indexed field 30 | /// for every document in the index. 31 | /// 32 | NoNorms 33 | } 34 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Util/ContextHelper.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Engine; 2 | using NHibernate.Event; 3 | using NHibernate.Search.Engine; 4 | using NHibernate.Search.Event; 5 | 6 | namespace NHibernate.Search.Util 7 | { 8 | internal static class ContextHelper 9 | { 10 | public static ISearchFactoryImplementor GetSearchFactory(ISession session) 11 | { 12 | return GetSearchFactoryBySFI((ISessionImplementor)session); 13 | } 14 | 15 | public static ISearchFactoryImplementor GetSearchFactoryBySFI(ISessionImplementor session) 16 | { 17 | IPostInsertEventListener[] listeners = session.Listeners.PostInsertEventListeners; 18 | FullTextIndexEventListener listener = null; 19 | 20 | // FIXME this sucks since we mandante the event listener use 21 | foreach (IPostInsertEventListener candidate in listeners) 22 | { 23 | if (candidate is FullTextIndexEventListener) 24 | { 25 | listener = (FullTextIndexEventListener)candidate; 26 | break; 27 | } 28 | } 29 | 30 | if (listener == null) 31 | { 32 | throw new HibernateException( 33 | "Hibernate Search Event listeners not configured, please check the reference documentation and the " 34 | + "application's hibernate.cfg.xml"); 35 | } 36 | 37 | return listener.SearchFactory; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 4 | True 5 | 6 | NHibernate.info 7 | NHibernate community, Hibernate community 8 | Licensed under LGPL. 9 | en-US 10 | 11 | https://nhibernate.info 12 | NHibernate; Search; Lucene; Lucene.Net; FullText; Text 13 | https://raw.githubusercontent.com/nhibernate/NHibernate-Search/master/images/logo.png 14 | logo.png 15 | false 16 | LGPL-2.1-only 17 | 18 | True 19 | snupkg 20 | 21 | True 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/log4net.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/AlternateDocument.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Search.Attributes; 2 | 3 | namespace NHibernate.Search.Tests 4 | { 5 | /// Example of 2 entities mapped in the same index 6 | [Indexed(Index = "Documents")] 7 | public class AlternateDocument 8 | { 9 | private int id; 10 | private string title; 11 | private string summary; 12 | private string text; 13 | 14 | public AlternateDocument() { } 15 | 16 | public AlternateDocument(int id, string title, string summary, string text) 17 | { 18 | this.id = id; 19 | this.title = title; 20 | this.summary = summary; 21 | this.text = text; 22 | } 23 | 24 | [DocumentId] 25 | public virtual int Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | [Field(Index.Tokenized, Store = Attributes.Store.Yes, Name = "alt_title")] 32 | [Boost(2)] 33 | public virtual string Title 34 | { 35 | get { return title; } 36 | set { title = value; } 37 | } 38 | 39 | [Field(Index.Tokenized, Name = "Abstract", Store = Attributes.Store.No)] 40 | public virtual string Summary 41 | { 42 | get { return summary; } 43 | set { summary = value; } 44 | } 45 | 46 | [Field(Index.Tokenized, Store = Attributes.Store.No)] 47 | public virtual string Text 48 | { 49 | get { return text; } 50 | set { text = value; } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Cfg/CfgXmlHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | using System.Xml.XPath; 3 | 4 | namespace NHibernate.Search.Cfg 5 | { 6 | /// 7 | /// Helper to parse nhv-configuration XmlNode. 8 | /// 9 | public static class CfgXmlHelper 10 | { 11 | public const string CfgNamespacePrefix = "cfg"; 12 | 13 | /// The XML Namespace for the nhibernate-configuration 14 | public const string CfgSchemaXMLNS = "urn:nhs-configuration-1.0"; 15 | 16 | /// 17 | /// The XML node name for hibernate configuration section in the App.config/Web.config and 18 | /// for the hibernate.cfg.xml . 19 | /// 20 | public const string CfgSectionName = "nhs-configuration"; 21 | 22 | public static readonly XPathExpression SearchFactoryExpression; 23 | 24 | public static readonly string SessionFactoryNameAttribute = "sessionFactoryName"; 25 | public static readonly string PropertyNameAttribute = "name"; 26 | public static readonly string PropertiesNodeName = "property"; 27 | 28 | private const string RootPrefixPath = "//" + CfgNamespacePrefix; 29 | 30 | private static readonly XmlNamespaceManager nsMgr; 31 | 32 | static CfgXmlHelper() 33 | { 34 | NameTable nt = new NameTable(); 35 | nsMgr = new XmlNamespaceManager(nt); 36 | nsMgr.AddNamespace(CfgNamespacePrefix, CfgSchemaXMLNS); 37 | 38 | SearchFactoryExpression = XPathExpression.Compile(RootPrefixPath + ":search-factory", nsMgr); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/CatFieldsClassBridge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Lucene.Net.Documents; 4 | using NHibernate.Search.Bridge; 5 | 6 | namespace NHibernate.Search.Tests.Bridge 7 | { 8 | public class CatFieldsClassBridge : IFieldBridge, IParameterizedBridge 9 | { 10 | private string sepChar; 11 | 12 | #region IFieldBridge Members 13 | 14 | public void Set(string name, object value, Document document, FieldType fieldType, float? boost) 15 | { 16 | // In this particular class the name of the new field was passed 17 | // from the name field of the ClassBridge Annotation. This is not 18 | // a requirement. It just works that way in this instance. The 19 | // actual name could be supplied by hard coding it below. 20 | Department dep = (Department)value; 21 | String fieldValue1 = dep.Branch ?? string.Empty; 22 | String fieldValue2 = dep.Network ?? string.Empty; 23 | String fieldValue = fieldValue1 + sepChar + fieldValue2; 24 | Field field = new Field(name, fieldValue, fieldType); 25 | if (boost != null) 26 | { 27 | field.Boost = (float)boost; 28 | } 29 | 30 | document.Add(field); 31 | } 32 | 33 | #endregion 34 | 35 | #region IParameterizedBridge Members 36 | 37 | public void SetParameterValues(Dictionary parameters) 38 | { 39 | sepChar = (string)parameters["sepChar"]; 40 | } 41 | 42 | #endregion 43 | } 44 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/CatDeptsFieldsClassBridge.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using Lucene.Net.Documents; 4 | 5 | using NHibernate.Search.Bridge; 6 | 7 | namespace NHibernate.Search.Tests.Bridge 8 | { 9 | public class CatDeptsFieldsClassBridge : IFieldBridge, IParameterizedBridge 10 | { 11 | private string sepChar; 12 | 13 | #region IFieldBridge Members 14 | 15 | public void Set(string name, object value, Document document, FieldType fieldType, float? boost) 16 | { 17 | // In this particular class the name of the new field was passed 18 | // from the name field of the ClassBridge Annotation. This is not 19 | // a requirement. It just works that way in this instance. The 20 | // actual name could be supplied by hard coding it below. 21 | Departments dep = (Departments)value; 22 | string fieldValue1 = dep.Branch ?? string.Empty; 23 | string fieldValue2 = dep.Network ?? string.Empty; 24 | string fieldValue = fieldValue1 + sepChar + fieldValue2; 25 | Field field = new Field(name, fieldValue, fieldType); 26 | if (boost != null) 27 | { 28 | field.Boost = (float)boost; 29 | } 30 | 31 | document.Add(field); 32 | } 33 | 34 | #endregion 35 | 36 | #region IParameterizedBridge Members 37 | 38 | public void SetParameterValues(Dictionary parameters) 39 | { 40 | sepChar = (string)parameters["sepChar"]; 41 | } 42 | 43 | #endregion 44 | } 45 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Embedded/DoubleInsert/Phone.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Tests.Embedded.DoubleInsert 4 | { 5 | using Attributes; 6 | 7 | [Indexed] 8 | public class Phone 9 | { 10 | [DocumentId] 11 | private long id; 12 | 13 | [Field(Index = Index.Tokenized, Store = Store.Yes)] 14 | private string number; 15 | 16 | [Field(Index = Index.Tokenized, Store = Store.Yes)] 17 | private string type; 18 | 19 | private DateTime createdOn; 20 | private DateTime lastUpdatedOn; 21 | 22 | [IndexedEmbedded] 23 | private Contact contact; 24 | 25 | public long Id 26 | { 27 | get { return id; } 28 | set { id = value; } 29 | } 30 | 31 | public string Number 32 | { 33 | get { return number; } 34 | set { number = value; } 35 | } 36 | 37 | public string Type 38 | { 39 | get 40 | { 41 | return string.IsNullOrEmpty(type) ? "N/A" : type; 42 | } 43 | set { type = value; } 44 | } 45 | 46 | public DateTime CreatedOn 47 | { 48 | get { return createdOn; } 49 | set { createdOn = value; } 50 | } 51 | 52 | public DateTime LastUpdatedOn 53 | { 54 | get { return lastUpdatedOn; } 55 | set { lastUpdatedOn = value; } 56 | } 57 | 58 | public Contact Contact 59 | { 60 | get { return contact; } 61 | set { contact = value; } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Analyzer/AbstractTestAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using Lucene.Net.Analysis; 3 | using Lucene.Net.Analysis.Standard; 4 | using Lucene.Net.Analysis.TokenAttributes; 5 | using Lucene.Net.Util; 6 | 7 | namespace NHibernate.Search.Tests.Analyzer 8 | { 9 | public abstract class AbstractTestAnalyzer : Lucene.Net.Analysis.Analyzer 10 | { 11 | protected abstract string[] Tokens { get; } 12 | 13 | protected override TokenStreamComponents CreateComponents(string fieldName, TextReader reader) 14 | { 15 | return new TokenStreamComponents( 16 | new StandardTokenizer(LuceneVersion.LUCENE_48, reader), 17 | new InternalTokenStream(Tokens)); 18 | } 19 | 20 | private sealed class InternalTokenStream : TokenStream 21 | { 22 | private readonly string[] tokens; 23 | private int position; 24 | private readonly IPayloadAttribute attribute; 25 | 26 | public InternalTokenStream(string[] tokens) 27 | { 28 | this.tokens = tokens; 29 | attribute = AddAttribute(); 30 | } 31 | 32 | public override bool IncrementToken() 33 | { 34 | ClearAttributes(); 35 | if (position < tokens.Length) 36 | { 37 | attribute.Payload = new BytesRef(tokens[position++]); 38 | } 39 | 40 | return false; 41 | } 42 | 43 | protected override void Dispose(bool disposing) 44 | { 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/LuceneWork.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Documents; 2 | 3 | namespace NHibernate.Search.Backend 4 | { 5 | public abstract class LuceneWork 6 | { 7 | private readonly Document document; 8 | private readonly System.Type entityClass; 9 | private readonly object id; 10 | private readonly string idInString; 11 | 12 | // Flag indicating that the lucene work has to be indexed in batch mode 13 | private bool isBatch; 14 | 15 | #region Constructors 16 | 17 | protected LuceneWork(object id, string idInString, System.Type entityClass) 18 | : this(id, idInString, entityClass, null) 19 | { 20 | } 21 | 22 | protected LuceneWork(object id, string idInString, System.Type entityClass, Document document) 23 | { 24 | this.id = id; 25 | this.idInString = idInString; 26 | this.entityClass = entityClass; 27 | this.document = document; 28 | } 29 | 30 | #endregion 31 | 32 | #region Property methods 33 | 34 | public System.Type EntityClass 35 | { 36 | get { return entityClass; } 37 | } 38 | 39 | public object Id 40 | { 41 | get { return id; } 42 | } 43 | 44 | public string IdInString 45 | { 46 | get { return idInString; } 47 | } 48 | 49 | public Document Document 50 | { 51 | get { return document; } 52 | } 53 | 54 | public bool IsBatch 55 | { 56 | get { return isBatch; } 57 | set { isBatch = value; } 58 | } 59 | 60 | #endregion 61 | } 62 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Store/Optimization/IOptimizerStrategy.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NHibernate.Search.Backend; 3 | using NHibernate.Search.Engine; 4 | 5 | namespace NHibernate.Search.Store.Optimization 6 | { 7 | /// 8 | /// Defines the index optimizer strategy 9 | /// 10 | public interface IOptimizerStrategy 11 | { 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | void Initialize(IDirectoryProvider directoryProvider, IDictionary indexProperties, 19 | ISearchFactoryImplementor searchFactoryImplementor); 20 | 21 | /// 22 | /// 23 | /// 24 | /// Has to be called in a thread safe way 25 | void OptimizationForced(); 26 | 27 | /// 28 | /// 29 | /// 30 | /// Has to be called in a thread safe way 31 | /// 32 | bool NeedOptimization { get; } 33 | 34 | /// 35 | /// 36 | /// 37 | /// Has to be called in a thread safe way 38 | /// 39 | void AddTransaction(long theOperations); 40 | 41 | /// 42 | /// 43 | /// 44 | /// Has to be called in a thread safe way 45 | /// 46 | void Optimize(Workspace workspace); 47 | } 48 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Cfg/INHSConfigCollection.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Cfg 2 | { 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// INHSConfigCollection contains a dictionary of instantiated 7 | /// objects. The API expects the key to be the NHibernate session factory name. 8 | /// 9 | /// 10 | /// The default concrete implementation is . 11 | /// 12 | public interface INHSConfigCollection : IDictionary 13 | { 14 | /// 15 | /// As a convenience, we will treat an INHSConfiguration with an empty key 16 | /// as the default confguration. 17 | /// 18 | bool HasDefaultConfiguration { get; } 19 | 20 | /// 21 | /// If collection has a default configuration, then return that instance. 22 | /// Otherwise, return null. 23 | /// 24 | INHSConfiguration DefaultConfiguration { get; } 25 | 26 | /// 27 | /// Gets the for the specified key. 28 | /// 29 | /// 30 | /// The NHibernate session factory name. 31 | /// 32 | /// 33 | /// If collection has an instance of for the named session factory, then return that instance. 34 | /// Otherwise, if collection has a default configuration, then return that instance. 35 | /// Otherwise, return null. 36 | /// 37 | INHSConfiguration GetConfiguration(string sessionFactoryName); 38 | } 39 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Worker/ConcurrencyTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | 5 | namespace NHibernate.Search.Tests.Worker 6 | { 7 | [TestFixture] 8 | public class ConcurrencyTest : SearchTestCase 9 | { 10 | protected override IEnumerable Mappings 11 | { 12 | get { return new string[] { "Worker.Drink.hbm.xml", "Worker.Food.hbm.xml" }; } 13 | } 14 | 15 | [Test] 16 | public void MultipleEntitiesInSameIndex() 17 | { 18 | ISession s = OpenSession(); 19 | ITransaction tx = s.BeginTransaction(); 20 | Drink d = new Drink(); 21 | d.Name = "Water"; 22 | Food f = new Food(); 23 | f.Name = "Bread"; 24 | s.Save(d); 25 | s.Save(f); 26 | tx.Commit(); 27 | s.Close(); 28 | 29 | s = OpenSession(); 30 | tx = s.BeginTransaction(); 31 | d = s.Get(d.Id); 32 | d.Name = "Coke"; 33 | f = s.Get(f.Id); 34 | f.Name = "Cake"; 35 | try 36 | { 37 | tx.Commit(); 38 | } 39 | catch // TODO: This Commit() succeeds, so I wonder why there is a try/catch 40 | { 41 | //Check for error logs from JDBCTransaction 42 | } 43 | s.Close(); 44 | 45 | s = OpenSession(); 46 | tx = s.BeginTransaction(); 47 | d = s.Get(d.Id); 48 | s.Delete(d); 49 | f = s.Get(f.Id); 50 | s.Delete(f); 51 | tx.Commit(); 52 | s.Close(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/TestConfigurationHelper.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Test 2 | { 3 | using System; 4 | using System.IO; 5 | using Cfg; 6 | 7 | public static class TestConfigurationHelper 8 | { 9 | public static readonly string hibernateConfigFile; 10 | 11 | static TestConfigurationHelper() 12 | { 13 | // Verify if hibernate.cfg.xml exists 14 | hibernateConfigFile = TestConfigurationHelper.GetDefaultConfigurationFilePath(); 15 | } 16 | 17 | public static string GetDefaultConfigurationFilePath() 18 | { 19 | string baseDir = AppDomain.CurrentDomain.BaseDirectory; 20 | string relativeSearchPath = AppDomain.CurrentDomain.RelativeSearchPath; 21 | string folder = relativeSearchPath == null ? baseDir : Path.Combine(baseDir, relativeSearchPath); 22 | while (folder != null) 23 | { 24 | string current = Path.Combine(folder, Configuration.DefaultHibernateCfgFileName); 25 | if (File.Exists(current)) 26 | return current; 27 | folder = Path.GetDirectoryName(folder); 28 | } 29 | 30 | return null; 31 | } 32 | 33 | /// 34 | /// Standar Configuration for tests. 35 | /// 36 | /// The configuration using merge between App.Config and hibernate.cfg.xml if present. 37 | public static Configuration GetDefaultConfiguration() 38 | { 39 | Configuration result = new Configuration(); 40 | if (hibernateConfigFile != null) 41 | result.Configure(hibernateConfigFile); 42 | return result; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/EquipmentType.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Lucene.Net.Documents; 3 | using NHibernate.Search.Bridge; 4 | 5 | namespace NHibernate.Search.Tests.Bridge 6 | { 7 | public class EquipmentType : IFieldBridge, IParameterizedBridge 8 | { 9 | private Dictionary equips; 10 | 11 | #region IFieldBridge Members 12 | 13 | public void Set(string name, object value, Document document, FieldType fieldType, float? boost) 14 | { 15 | // In this particular class the name of the new field was passed 16 | // from the name field of the ClassBridge Annotation. This is not 17 | // a requirement. It just works that way in this instance. The 18 | // actual name could be supplied by hard coding it below. 19 | Departments deps = (Departments)value; 20 | Field field = null; 21 | string fieldValue1 = deps.Manufacturer; 22 | 23 | if (fieldValue1 == null) 24 | fieldValue1 = string.Empty; 25 | else 26 | { 27 | string fieldValue = (string)equips[fieldValue1]; 28 | field = new Field(name, fieldValue, fieldType); 29 | if (boost != null) 30 | field.Boost = (float)boost; 31 | } 32 | 33 | document.Add(field); 34 | } 35 | 36 | #endregion 37 | 38 | #region IParameterizedBridge Members 39 | 40 | public void SetParameterValues(Dictionary parameters) 41 | { 42 | // This map was defined by the parameters of the ClassBridge annotation. 43 | equips = parameters; 44 | } 45 | 46 | #endregion 47 | } 48 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/IndexedEmbedded.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Specifies that an association (ToOne or Embedded) is to be indexed in the root entity index 7 | /// 8 | /// 9 | /// It allows queries involving associated objects restrictions 10 | /// 11 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Field, AllowMultiple = false)] 12 | public class IndexedEmbeddedAttribute : Attribute 13 | { 14 | private string prefix = "."; 15 | private int depth = int.MaxValue; 16 | private System.Type targetElement; 17 | 18 | /// 19 | /// Field name prefix 20 | /// Default to 'propertyname.' 21 | /// 22 | public string Prefix 23 | { 24 | get { return prefix; } 25 | set { prefix = value; } 26 | } 27 | 28 | /// 29 | // Stop indexing embedded elements when depth is reached 30 | // depth=1 means the associated element is index, but not its embedded elements 31 | // Default: infinite (an exception will be raised in case of class circular reference when infinite is chosen) 32 | /// 33 | public int Depth 34 | { 35 | get { return depth; } 36 | set { depth = value; } 37 | } 38 | 39 | /// 40 | /// Overrides the type of an association. If a collection, overrides the type of the collection generics 41 | /// 42 | public System.Type TargetElement 43 | { 44 | get { return targetElement; } 45 | set { targetElement = value; } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Cfg/nhs-configuration.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Default values: 12 | analyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net 13 | indexBase = . 14 | indexBase.create = false 15 | default.directory_provider = NHibernate.Search.Storage.FSDirectoryProvider, NHibernate.Search 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/PhysicalTestCase.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | using Lucene.Net.Analysis.Core; 4 | 5 | using NHibernate.Cfg; 6 | using NHibernate.Search.Store; 7 | 8 | namespace NHibernate.Search.Tests 9 | { 10 | public abstract partial class PhysicalTestCase : SearchTestCase 11 | { 12 | protected FileInfo BaseIndexDir 13 | { 14 | get 15 | { 16 | FileInfo current = new FileInfo("."); 17 | FileInfo sub = new FileInfo(Path.Combine(current.FullName, "indextemp")); 18 | return sub; 19 | } 20 | } 21 | 22 | protected override void Configure(Configuration configuration) 23 | { 24 | base.Configure(configuration); 25 | DeleteBaseIndexDir(); 26 | FileInfo sub = BaseIndexDir; 27 | Directory.CreateDirectory(sub.FullName); 28 | 29 | configuration.SetProperty("hibernate.search.default.indexBase", sub.FullName); 30 | configuration.SetProperty("hibernate.search.default.directory_provider", typeof(FSDirectoryProvider).AssemblyQualifiedName); 31 | configuration.SetProperty(NHibernate.Search.Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName); 32 | } 33 | 34 | protected void DeleteBaseIndexDir() 35 | { 36 | FileInfo sub = BaseIndexDir; 37 | try 38 | { 39 | Delete(sub); 40 | } 41 | catch (IOException ex) 42 | { 43 | System.Diagnostics.Debug.WriteLine(ex); // "The process cannot access the file '_0.cfs' because it is being used by another process." 44 | } 45 | } 46 | 47 | protected override void OnTearDown() 48 | { 49 | base.OnTearDown(); 50 | 51 | DeleteBaseIndexDir(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/WorkQueue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NHibernate.Search.Backend 4 | { 5 | /// 6 | /// 7 | /// 8 | public class WorkQueue 9 | { 10 | //TODO set a serial number 11 | private List queue; 12 | 13 | private List sealedQueue; 14 | 15 | public WorkQueue(int size) 16 | { 17 | queue = new List(size); 18 | } 19 | 20 | private WorkQueue(List queue) 21 | { 22 | this.queue = queue; 23 | } 24 | 25 | public WorkQueue() : this(10) 26 | { 27 | } 28 | 29 | public void Add(Work work) 30 | { 31 | queue.Add(work); 32 | } 33 | 34 | public List GetQueue() 35 | { 36 | return queue; 37 | } 38 | 39 | public WorkQueue SplitQueue() 40 | { 41 | WorkQueue subQueue = new WorkQueue(queue); 42 | queue = new List(queue.Count); 43 | return subQueue; 44 | } 45 | 46 | public List GetSealedQueue() 47 | { 48 | if (sealedQueue == null) 49 | throw new AssertionFailure("Access a Sealed WorkQueue which has not been sealed"); 50 | return sealedQueue; 51 | } 52 | 53 | public void SetSealedQueue(List sealedQueue) 54 | { 55 | //invalidate the working queue for serializability 56 | queue = null; 57 | this.sealedQueue = sealedQueue; 58 | } 59 | 60 | public void Clear() 61 | { 62 | queue.Clear(); 63 | if (sealedQueue != null) sealedQueue.Clear(); 64 | } 65 | 66 | public int Count 67 | { 68 | get { return queue.Count; } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Session/OptimizeTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Lucene.Net.Util; 3 | 4 | namespace NHibernate.Search.Tests.Session 5 | { 6 | using System.Collections; 7 | 8 | using Impl; 9 | 10 | using Lucene.Net.Analysis.Core; 11 | using Lucene.Net.QueryParsers.Classic; 12 | 13 | using NUnit.Framework; 14 | 15 | [TestFixture] 16 | public class OptimizeTest : PhysicalTestCase 17 | { 18 | protected override IEnumerable Mappings 19 | { 20 | get { return new string[] { "Session.Email.hbm.xml" }; } 21 | } 22 | 23 | [Test] 24 | public void Optimize() 25 | { 26 | IFullTextSession s = Search.CreateFullTextSession(OpenSession()); 27 | ITransaction tx = s.BeginTransaction(); 28 | int loop = 2000; 29 | for (int i = 0; i < loop; i++) 30 | { 31 | s.Persist(new Email(i + 1, "JBoss World Berlin", "Meet the guys who wrote the software")); 32 | } 33 | 34 | tx.Commit(); 35 | s.Close(); 36 | 37 | s = Search.CreateFullTextSession(OpenSession()); 38 | tx = s.BeginTransaction(); 39 | s.SearchFactory.Optimize(typeof(Email)); 40 | tx.Commit(); 41 | s.Close(); 42 | 43 | // Check non-indexed object get indexed by s.index; 44 | s = new FullTextSessionImpl(OpenSession()); 45 | tx = s.BeginTransaction(); 46 | QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "id", new StopAnalyzer(LuceneVersion.LUCENE_48)); 47 | int result = s.CreateFullTextQuery(parser.Parse("Body:wrote")).List().Count; 48 | Assert.AreEqual(2000, result); 49 | 50 | s.Delete("from System.Object"); 51 | tx.Commit(); 52 | s.Close(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Store/IdHashShardingStrategy.cs: -------------------------------------------------------------------------------- 1 | using Lucene.Net.Documents; 2 | 3 | namespace NHibernate.Search.Store 4 | { 5 | using System; 6 | 7 | public class IdHashShardingStrategy : IIndexShardingStrategy 8 | { 9 | private IDirectoryProvider[] providers; 10 | 11 | #region Public methods 12 | 13 | public void Initialize(object properties, IDirectoryProvider[] providers) 14 | { 15 | if (providers == null) 16 | { 17 | throw new ArgumentNullException("providers"); 18 | } 19 | 20 | this.providers = providers; 21 | } 22 | 23 | public IDirectoryProvider[] GetDirectoryProvidersForAllShards() 24 | { 25 | return providers; 26 | } 27 | 28 | public IDirectoryProvider GetDirectoryProviderForAddition(System.Type entity, object id, string idInString, 29 | Document document) 30 | { 31 | return providers[HashKey(idInString)]; 32 | } 33 | 34 | public IDirectoryProvider[] GetDirectoryProvidersForDeletion(System.Type entity, object id, string idInString) 35 | { 36 | return string.IsNullOrEmpty(idInString) 37 | ? providers 38 | : new IDirectoryProvider[] { providers[HashKey(idInString)] }; 39 | } 40 | 41 | #endregion 42 | 43 | #region Private methods 44 | 45 | private int HashKey(string key) 46 | { 47 | // Reproduce the JavaDoc version of String.hashCode so we shard the same way. 48 | int hash = 0; 49 | foreach (char c in key) 50 | { 51 | hash = (31 * hash) + c; 52 | } 53 | 54 | return hash % providers.GetLength(0); 55 | } 56 | 57 | #endregion 58 | } 59 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Engine/ISearchFactoryImplementor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NHibernate.Search.Backend; 3 | using NHibernate.Search.Filter; 4 | using NHibernate.Search.Store; 5 | using NHibernate.Search.Store.Optimization; 6 | 7 | namespace NHibernate.Search.Engine 8 | { 9 | /// 10 | /// Interface which gives access to the different directory providers and their configuration. 11 | /// 12 | public interface ISearchFactoryImplementor : ISearchFactory 13 | { 14 | IBackendQueueProcessorFactory BackendQueueProcessorFactory { get; set; } 15 | 16 | IDictionary DocumentBuilders { get; } 17 | 18 | Dictionary GetLockableDirectoryProviders(); 19 | 20 | IWorker Worker { get; } 21 | 22 | void AddOptimizerStrategy(IDirectoryProvider provider, IOptimizerStrategy optimizerStrategy); 23 | 24 | IOptimizerStrategy GetOptimizerStrategy(IDirectoryProvider provider); 25 | 26 | IFilterCachingStrategy GetFilterCachingStrategy(); 27 | 28 | LuceneIndexingParameters GetIndexingParameters(IDirectoryProvider provider); 29 | 30 | void AddIndexingParameters(IDirectoryProvider provider, LuceneIndexingParameters indexingParameters); 31 | 32 | void Close(); 33 | 34 | /// 35 | /// Adds a FilterDef object to the ISearchFactory implementation with the given name. 36 | /// In most cases, FilterDefs should be added during mapping configuration in a 37 | /// custom ISearchMapping implementation. This method enables FilterDefs to be added 38 | /// after mapping at run-time anytime an IFullTextSession is available. 39 | /// 40 | /// 41 | /// 42 | void AddFilterDefinition(string name, FilterDef filter); 43 | } 44 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Attributes/FullTextFilterDefAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NHibernate.Search.Attributes 4 | { 5 | /// 6 | /// Defines a FullTextFilter that can be optionally applied to every FullText Queries 7 | /// While not related to a specific indexed entity, the annotation has to be set on one of them 8 | /// 9 | /// We allow multiple instances of this attribute rather than having a FullTextFilterDefsAttribute as per Java 10 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 11 | public class FullTextFilterDefAttribute : Attribute 12 | { 13 | private readonly string name; 14 | private readonly System.Type impl; 15 | private bool cache = true; 16 | 17 | public FullTextFilterDefAttribute(string name, System.Type impl) 18 | { 19 | this.name = name; 20 | this.impl = impl; 21 | } 22 | 23 | /// 24 | /// Filter name. Must be unique accross all mappings for a given persistence unit 25 | /// 26 | public string Name 27 | { 28 | get { return name; } 29 | } 30 | 31 | /// 32 | /// Either implements 33 | /// or contains a method returning one. 34 | /// The Filter generated must be thread-safe 35 | /// 36 | /// If the filter accept parameters, an method must be present as well. 37 | /// 38 | public System.Type Impl 39 | { 40 | get { return impl; } 41 | } 42 | 43 | /// 44 | /// Enable caching for this filter (default true). 45 | /// 46 | public bool Cache 47 | { 48 | get { return cache; } 49 | set { cache = value; } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Backend/Impl/PostTransactionWorkQueueSynchronization.cs: -------------------------------------------------------------------------------- 1 | using NHibernate.Transaction; 2 | using NHibernate.Util; 3 | 4 | namespace NHibernate.Search.Backend.Impl 5 | { 6 | internal partial class PostTransactionWorkQueueSynchronization : ITransactionCompletionSynchronization 7 | { 8 | private bool isConsumed; 9 | private WorkQueue queue = new WorkQueue(); 10 | private IQueueingProcessor queueingProcessor; 11 | private WeakHashtable queuePerTransaction; 12 | /** 13 | * in transaction work 14 | */ 15 | 16 | public PostTransactionWorkQueueSynchronization(IQueueingProcessor queueingProcessor, 17 | WeakHashtable queuePerTransaction) 18 | { 19 | this.queueingProcessor = queueingProcessor; 20 | this.queuePerTransaction = queuePerTransaction; 21 | } 22 | public void ExecuteBeforeTransactionCompletion() 23 | { 24 | queueingProcessor.PrepareWorks(queue); 25 | } 26 | 27 | public void ExecuteAfterTransactionCompletion(bool success) 28 | { 29 | try 30 | { 31 | if (success) 32 | queueingProcessor.PerformWorks(queue); 33 | else 34 | queueingProcessor.CancelWorks(queue); 35 | } 36 | finally 37 | { 38 | isConsumed = true; 39 | //clean the Synchronization per Transaction 40 | //not needed in a strict sensus but a cleaner approach and faster than the GC 41 | if (queuePerTransaction != null) queuePerTransaction.Remove(this); 42 | } 43 | } 44 | 45 | public void Add(Work work) 46 | { 47 | queueingProcessor.Add(work, queue); 48 | } 49 | 50 | public bool IsConsumed 51 | { 52 | get { return isConsumed; } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Reader/NotSharedReaderProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Lucene.Net.Index; 4 | using NHibernate.Search.Engine; 5 | using NHibernate.Search.Impl; 6 | using NHibernate.Search.Store; 7 | 8 | namespace NHibernate.Search.Reader 9 | { 10 | /// 11 | /// Open a reader each time 12 | /// 13 | public class NotSharedReaderProvider : IReaderProvider 14 | { 15 | public IndexReader OpenReader(IDirectoryProvider[] directoryProviders) 16 | { 17 | int length = directoryProviders.Length; 18 | IndexReader[] readers = new IndexReader[length]; 19 | try 20 | { 21 | for (int index = 0; index < length; index++) 22 | readers[index] = DirectoryReader.Open(directoryProviders[index].Directory); 23 | } 24 | catch (System.IO.IOException ex) 25 | { 26 | // TODO: more contextual info 27 | ReaderProviderHelper.Clean(readers); 28 | throw new SearchException("Unable to open one of the Lucene indexes", ex); 29 | } 30 | 31 | return ReaderProviderHelper.BuildMultiReader(length, readers); 32 | } 33 | 34 | public void CloseReader(IndexReader reader) 35 | { 36 | try 37 | { 38 | reader.Dispose(); 39 | } 40 | catch (System.IO.IOException ex) 41 | { 42 | //TODO: extract subReaders and close each one individually 43 | ReaderProviderHelper.Clean(reader); 44 | new SearchException("Unable to close multiReader", ex); 45 | } 46 | } 47 | 48 | public void Initialize(IDictionary properties, 49 | ISearchFactoryImplementor searchFactoryImplementor) 50 | { 51 | } 52 | 53 | public void Destroy() 54 | { 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/NHibernate.Search/Async/Backend/Impl/PostTransactionWorkQueueSynchronization.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by AsyncGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | 11 | using NHibernate.Transaction; 12 | using NHibernate.Util; 13 | 14 | namespace NHibernate.Search.Backend.Impl 15 | { 16 | using System.Threading.Tasks; 17 | using System.Threading; 18 | internal partial class PostTransactionWorkQueueSynchronization : ITransactionCompletionSynchronization 19 | { 20 | public Task ExecuteBeforeTransactionCompletionAsync(CancellationToken cancellationToken) 21 | { 22 | if (cancellationToken.IsCancellationRequested) 23 | { 24 | return Task.FromCanceled(cancellationToken); 25 | } 26 | try 27 | { 28 | ExecuteBeforeTransactionCompletion(); 29 | return Task.CompletedTask; 30 | } 31 | catch (System.Exception ex) 32 | { 33 | return Task.FromException(ex); 34 | } 35 | } 36 | 37 | public Task ExecuteAfterTransactionCompletionAsync(bool success, CancellationToken cancellationToken) 38 | { 39 | if (cancellationToken.IsCancellationRequested) 40 | { 41 | return Task.FromCanceled(cancellationToken); 42 | } 43 | try 44 | { 45 | ExecuteAfterTransactionCompletion(success); 46 | return Task.CompletedTask; 47 | } 48 | catch (System.Exception ex) 49 | { 50 | return Task.FromException(ex); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/NHibernate.Search.Tests/Bridge/Department.cs: -------------------------------------------------------------------------------- 1 | namespace NHibernate.Search.Tests.Bridge 2 | { 3 | using Attributes; 4 | 5 | [Indexed] 6 | [ClassBridge(typeof(CatFieldsClassBridge), 7 | Name = "branchnetwork", 8 | Index = Index.Tokenized, 9 | Store = Attributes.Store.Yes)] 10 | [Parameter("sepChar", " ")] 11 | public class Department 12 | { 13 | private int id; 14 | private string network; 15 | private string branchHead; 16 | private string branch; 17 | private int maxEmployees; 18 | 19 | /// 20 | /// 21 | /// 22 | [DocumentId] 23 | public virtual int Id 24 | { 25 | get { return id; } 26 | set { id = value; } 27 | } 28 | 29 | /// 30 | /// 31 | /// 32 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)] 33 | public virtual string BranchHead 34 | { 35 | get { return branchHead; } 36 | set { branchHead = value; } 37 | } 38 | 39 | /// 40 | /// 41 | /// 42 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)] 43 | public virtual string Network 44 | { 45 | get { return network; } 46 | set { network = value; } 47 | } 48 | 49 | /// 50 | /// 51 | /// 52 | [Field(Index.Tokenized, Store = Attributes.Store.Yes)] 53 | public virtual string Branch 54 | { 55 | get { return branch; } 56 | set { branch = value; } 57 | } 58 | 59 | /// 60 | /// 61 | /// 62 | [Field(Index.UnTokenized, Store = Attributes.Store.Yes)] 63 | public virtual int MaxEmployees 64 | { 65 | get { return maxEmployees; } 66 | set { maxEmployees = value; } 67 | } 68 | } 69 | } 70 | --------------------------------------------------------------------------------