public void CreateIndex(string name, FieldDefinitionCollection fields, Analyzer analyzer = null) { if (analyzer == null) { analyzer = new KeywordAnalyzer(); } // examineIndex.WaitForIndexQueueOnShutdown = false; _examineManager.TryGetIndex(name, out var index); if (index == null) { var dir = examineIndex.GetLuceneDirectory(); if (!string.IsNullOrEmpty(dir.GetLockID())) { // _loggingService.Info("Forcing index {IndexerName} to be unlocked since it was left in a locked state", examineIndex.Name); dir.ClearLock("write.lock"); } if (IndexWriter.IsLocked(dir)) { IndexWriter.Unlock(dir); } } }
public virtual void VisitFieldDefinitionCollection(FieldDefinitionCollection fields) { foreach (FieldDefinition field in fields) { VisitFieldDefinition(field); } }
public ContentElasticSearchIndex(string name, ElasticSearchConfig connectionConfiguration, IProfilingLogger profilingLogger, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null, bool publishedValuesOnly = false) : base(name, connectionConfiguration, profilingLogger, fieldDefinitions, analyzer, validator) { PublishedValuesOnly = publishedValuesOnly; }
public void VisitFieldDefinitionCollection(FieldDefinitionCollection fields) { foreach (FieldDefinition field in fields) { AppendNode(field.DeclaringType, field, false); } }
public TestBaseIndex(ElasticSearchConfig connectionConfiguration, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null) : base("testIndexer", connectionConfiguration, fieldDefinitions, analyzer, validator) { }
private void AddUsedTypesFromFields(FieldDefinitionCollection fields, List <UsedClass> usedT) { foreach (FieldDefinition ifd in fields) { AddTypeToList(ifd.FieldType, ClassUse.Contains, usedT); } }
public override void VisitFieldDefinitionCollection(FieldDefinitionCollection fields) { foreach (FieldDefinition field in fields) { VisitFieldDefinition(field); } }
static void ProcessFields(FieldDefinitionCollection fields) { foreach (FieldDefinition field in fields) { ProcessField(field); } }
private void CreateNewIndex() { lock (ExistsLocker) { var fields = FieldDefinitionCollection.Select(CreateField).ToList(); //id must be string fields.Add(new Field(FormatFieldName(LuceneIndex.ItemIdFieldName), DataType.String) { IsKey = true, IsSortable = true, IsSearchable = true, Analyzer = AnalyzerName.Whitespace }); fields.Add(new Field(FormatFieldName(LuceneIndex.ItemTypeFieldName), DataType.String) { IsSearchable = true, Analyzer = AnalyzerName.Whitespace }); fields.Add(new Field(FormatFieldName(LuceneIndex.CategoryFieldName), DataType.String) { IsSearchable = true, Analyzer = AnalyzerName.Whitespace }); //TODO: We should have a custom event for devs to modify the AzureSearch data directly here var index = _client.Value.Indexes.Create(new Index(Name, fields)); _exists = true; } }
FieldDefinition [] GetFields(TypeDefinition type) { ArrayList list = new ArrayList(); FieldDefinitionCollection fields = type.Fields; foreach (FieldDefinition field in fields) { if (field.IsSpecialName) { continue; } // we're only interested in public or protected members FieldAttributes maskedVisibility = (field.Attributes & FieldAttributes.FieldAccessMask); if (maskedVisibility == FieldAttributes.Public || maskedVisibility == FieldAttributes.Family || maskedVisibility == FieldAttributes.FamORAssem) { list.Add(field); } } return((FieldDefinition [])list.ToArray(typeof(FieldDefinition))); }
public MemberElasticSearchIndex(string name, ElasticSearchConfig connectionConfiguration, IPublicAccessService publicAccessService, IProfilingLogger profilingLogger, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null) : base(name, connectionConfiguration, publicAccessService, profilingLogger, fieldDefinitions, analyzer, validator) { }
public PdfLuceneIndex(string name, Directory luceneDirectory, FieldDefinitionCollection fieldDefinitions, Analyzer analyzer, PdfValueSetValidator validator, IProfilingLogger logger, IReadOnlyDictionary <string, IFieldValueTypeFactory> indexValueTypesFactory = null) : base(name, luceneDirectory, fieldDefinitions, analyzer, validator, indexValueTypesFactory) { _diagnostics = new PdfIndexDiagnostics(this, logger); }
public override SelectResult ExecuteSelect(AdamDataSourceSelectingEventArgs arguments) { var selectResult = new SelectResult<FieldInheritanceDefinition>(); var definitionCollection = new FieldDefinitionCollection(App); var isLastPage = LoadFieldsPage(definitionCollection, arguments); var inheritanceDefinitions = LoadDefinitionsFor(definitionCollection).ToList(); selectResult.SetItems(arguments, inheritanceDefinitions, isLastPage); return selectResult; }
/// <summary> /// Constructor to allow for creating an indexer at runtime /// </summary> /// <param name="name"></param> /// <param name="fieldDefinitions"></param> /// <param name="luceneDirectory"></param> /// <param name="profilingLogger"></param> /// <param name="validator"></param> /// <param name="analyzer"></param> public UmbracoMemberIndex( string name, FieldDefinitionCollection fieldDefinitions, Directory luceneDirectory, Analyzer analyzer, IProfilingLogger profilingLogger, IValueSetValidator validator = null) : base(name, luceneDirectory, fieldDefinitions, analyzer, profilingLogger, validator) { }
/// <summary> /// Constructor for creating an indexer at runtime /// </summary> /// <param name="name"></param> /// <param name="fieldDefinitions"></param> /// <param name="validator"></param> protected BaseIndexProvider(string name, FieldDefinitionCollection fieldDefinitions, IValueSetValidator validator) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)); } Name = name; FieldDefinitionCollection = fieldDefinitions ?? throw new ArgumentNullException(nameof(fieldDefinitions)); ValueSetValidator = validator; }
public override SelectResult ExecuteSelect(AdamDataSourceSelectingEventArgs arguments) { var selectResult = new SelectResult <FieldInheritanceDefinition>(); var definitionCollection = new FieldDefinitionCollection(App); var isLastPage = LoadFieldsPage(definitionCollection, arguments); var inheritanceDefinitions = LoadDefinitionsFor(definitionCollection).ToList(); selectResult.SetItems(arguments, inheritanceDefinitions, isLastPage); return(selectResult); }
/// <summary> /// Create a new <see cref="UmbracoExamineIndex"/> /// </summary> /// <param name="name"></param> /// <param name="fieldDefinitions"></param> /// <param name="luceneDirectory"></param> /// <param name="defaultAnalyzer"></param> /// <param name="profilingLogger"></param> /// <param name="validator"></param> /// <param name="indexValueTypes"></param> protected ElasticSearchUmbracoIndex(string name, ElasticSearchConfig connectionConfiguration, IProfilingLogger profilingLogger, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null) : base(name, connectionConfiguration, fieldDefinitions, analyzer, validator, true) { _logger = profilingLogger; }
private PropertiesDescriptor <Document> CreateFieldsMapping(PropertiesDescriptor <Document> descriptor, FieldDefinitionCollection fieldDefinitionCollection) { foreach (FieldDefinition field in fieldDefinitionCollection) { FromExamineType(descriptor, field); } return(descriptor); }
public void Initialize() { _fieldDefinitions = new FieldDefinitionCollection(); _valueGroup = new FieldDefinitionGroup(); _errorGroup = new FieldDefinitionGroup(); _nameField = _fieldDefinitions.DefineField <string>(_valueGroup); _salaryField = _fieldDefinitions.DefineField <decimal>(_valueGroup); _addressField = _fieldDefinitions.DefineField <Address>(_valueGroup); _salaryErrorField = _fieldDefinitions.DefineField <string>(_errorGroup); }
private static bool DoHasNonStaticField(FieldDefinitionCollection fields) { foreach (FieldDefinition field in fields) { if ((field.Attributes & FieldAttributes.Static) == 0) { return(true); } } return(false); }
internal FieldDefinition( FieldDefinitionCollection parent, int groupIndex, int fieldIndex ) { Check.NotNull(parent, nameof(parent)); Parent = parent; GroupIndex = groupIndex; FieldIndex = fieldIndex; }
internal static FieldDefinitionCollectionWrapper GetInstance() { FieldDefinitionCollection real = default(FieldDefinitionCollection); RealInstanceFactory(ref real); var instance = (FieldDefinitionCollectionWrapper)FieldDefinitionCollectionWrapper.GetWrapper(real); InstanceFactory(ref instance); if (instance == null) { Assert.Inconclusive("Could not Create Test Instance"); } return(instance); }
public void CanAddFieldDefinitions() { var fd = new FieldDefinition <int>(); fd.Id = 1; var fdc = new FieldDefinitionCollection <int>(null, null); fdc.Add(fd); Assert.IsTrue(fdc.Count == 1); Assert.AreSame(fdc.First().Value, fd); Assert.AreSame(fdc[1], fd); }
public AzureSearchIndex( string name, string searchServiceName, string apiKey, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null) : base(name.ToLowerInvariant(), //TODO: Need to 'clean' the name according to Azure Search rules fieldDefinitions ?? new FieldDefinitionCollection(), validator) { _searchServiceName = searchServiceName; _apiKey = apiKey; Analyzer = analyzer ?? "standard.lucene"; _searcher = new Lazy <AzureSearchSearcher>(CreateSearcher); _client = new Lazy <ISearchServiceClient>(CreateSearchServiceClient); }
public void Setup() { _dynamicFields = new FieldDefinitionCollection(); _fieldValues = _dynamicFields.CreateValueHolder(); _innerAccessor = new InnerAccessor(); _behavior = new DisplayValueAccessorBehavior <int>(); //((IBehavior)_behavior).Initialize(new BehaviorInitializationContext("Test", _dynamicFields)); _behavior.Successor = _innerAccessor; var mock = new Mock <IBehaviorContext>(); mock.Setup(x => x.FieldValues).Returns(_fieldValues); _context = mock.Object; }
public ElasticSearchBaseIndex(string name, ElasticSearchConfig connectionConfiguration, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null, bool isUmbraco = false) : base(name.ToLowerInvariant(), //TODO: Need to 'clean' the name according to Azure Search rules fieldDefinitions ?? new FieldDefinitionCollection(), validator) { _connectionConfiguration = connectionConfiguration; _isUmbraco = isUmbraco; Analyzer = analyzer; ElasticURL = ConfigurationManager.AppSettings[$"examine:ElasticSearch[{name}].Url"]; _searcher = new Lazy <ElasticSearchSearcher>(CreateSearcher); _client = new Lazy <ElasticClient>(CreateElasticSearchClient); indexAlias = prefix + Name; tempindexAlias = indexAlias + "temp"; }
public ElasticSearchIndex(string name, ElasticSearchConfig connectionConfiguration, IPublicAccessService publicAccessService, IProfilingLogger profilingLogger, FieldDefinitionCollection fieldDefinitions = null, string analyzer = null, IValueSetValidator validator = null) : base(name.ToLowerInvariant(), //TODO: Need to 'clean' the name according to Azure Search rules fieldDefinitions ?? new FieldDefinitionCollection(), validator) { _connectionConfiguration = connectionConfiguration; _logger = profilingLogger; Analyzer = analyzer; ElasticURL = ConfigurationManager.AppSettings[$"examine:ElasticSearch[{name}].Url"]; _searcher = new Lazy <ElasticSearchSearcher>(CreateSearcher); _client = new Lazy <ElasticClient>(CreateElasticSearchClient); indexAlias = prefix + indexName; }
private bool LoadFieldsPage(FieldDefinitionCollection definitionCollection, AdamDataSourceSelectingEventArgs arguments) { var pageNumber = arguments.PageNumber + 1; var loadOptions = arguments.LoadOptions as FieldDefinitionLoadOptions; var maxRows = arguments.MaximumRows; var pageSize = arguments.PageSize; var sortExpression = arguments.SortExpression; var searchExpression = arguments.SelectExpression; bool isLastPage; do { definitionCollection.Load(searchExpression, sortExpression, pageNumber, pageSize, out isLastPage, maxRows, loadOptions); --pageNumber; }while (definitionCollection.Count == 0 && pageNumber > 0); arguments.PageNumber = pageNumber; return(isLastPage); }
public override PropertiesDescriptor <Document> CreateFieldsMapping(PropertiesDescriptor <Document> descriptor, FieldDefinitionCollection fieldDefinitionCollection) { descriptor.Keyword(s => s.Name("Id")); descriptor.Keyword(s => s.Name(FormatFieldName(LuceneIndex.ItemIdFieldName))); descriptor.Keyword(s => s.Name(FormatFieldName(LuceneIndex.ItemTypeFieldName))); descriptor.Keyword(s => s.Name(FormatFieldName(LuceneIndex.CategoryFieldName))); foreach (FieldDefinition field in fieldDefinitionCollection) { FromExamineType(descriptor, field); } var docArgs = new MappingOperationEventArgs(descriptor); onMapping(docArgs); return(descriptor); }
public void DefineFields() { FieldDefinitionCollection fieldDefinitions = new FieldDefinitionCollection(); FieldDefinitionGroup valueGroup = new FieldDefinitionGroup(); FieldDefinitionGroup errorGroup = new FieldDefinitionGroup(); FieldDefinition <string> nameField = fieldDefinitions.DefineField <string>(valueGroup); FieldDefinition <decimal> salaryField = fieldDefinitions.DefineField <decimal>(valueGroup); FieldDefinition <string> salaryErrorField = fieldDefinitions.DefineField <string>(errorGroup); Assert.AreEqual(0, nameField.GroupIndex); Assert.AreEqual(0, salaryField.GroupIndex); Assert.AreEqual(1, salaryErrorField.GroupIndex); Assert.AreEqual(0, nameField.FieldIndex); Assert.AreEqual(1, salaryField.FieldIndex); Assert.AreEqual(0, salaryErrorField.FieldIndex); }
private IEnumerable<FieldInheritanceDefinitionInfo> LoadDefinitionsFor(FieldDefinitionCollection fieldDefinitionCollection) { var inheritances = new FieldInheritanceDefinitionCollection(App); inheritances.Load(fieldDefinitionCollection.CopyIdsToArray()); foreach (FieldDefinition fieldDefinition in fieldDefinitionCollection) { var fieldId = fieldDefinition.Id; var foundInheritance = inheritances.FirstOrDefault(x => x.FieldId == fieldId); if (foundInheritance != null) { yield return CreateInfoInstance(fieldDefinition, foundInheritance); } else { yield return CreateInfoInstance(fieldDefinition); } } }
private IEnumerable <FieldInheritanceDefinitionInfo> LoadDefinitionsFor(FieldDefinitionCollection fieldDefinitionCollection) { var inheritances = new FieldInheritanceDefinitionCollection(App); inheritances.Load(fieldDefinitionCollection.CopyIdsToArray()); foreach (FieldDefinition fieldDefinition in fieldDefinitionCollection) { var fieldId = fieldDefinition.Id; var foundInheritance = inheritances.FirstOrDefault(x => x.FieldId == fieldId); if (foundInheritance != null) { yield return(CreateInfoInstance(fieldDefinition, foundInheritance)); } else { yield return(CreateInfoInstance(fieldDefinition)); } } }
private bool LoadFieldsPage(FieldDefinitionCollection definitionCollection, AdamDataSourceSelectingEventArgs arguments) { var pageNumber = arguments.PageNumber + 1; var loadOptions = arguments.LoadOptions as FieldDefinitionLoadOptions; var maxRows = arguments.MaximumRows; var pageSize = arguments.PageSize; var sortExpression = arguments.SortExpression; var searchExpression = arguments.SelectExpression; bool isLastPage; do { definitionCollection.Load(searchExpression, sortExpression, pageNumber, pageSize, out isLastPage, maxRows, loadOptions); --pageNumber; } while (definitionCollection.Count == 0 && pageNumber > 0); arguments.PageNumber = pageNumber; return isLastPage; }