本文整理汇总了C#中Nest.ConnectionSettings.SetDefaultIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionSettings.SetDefaultIndex方法的具体用法?C# ConnectionSettings.SetDefaultIndex怎么用?C# ConnectionSettings.SetDefaultIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nest.ConnectionSettings
的用法示例。
在下文中一共展示了ConnectionSettings.SetDefaultIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReIndexAll
public ActionResult ReIndexAll()
{
var documents = db.Documents.ToList();
var uriString = ConfigurationManager.AppSettings["SEARCHBOX_URL"];
var searchBoxUri = new Uri(uriString);
var settings = new ConnectionSettings(searchBoxUri);
settings.SetDefaultIndex("sample");
var client = new ElasticClient(settings);
// delete index if exists at startup
if (client.IndexExists("sample").Exists)
{
client.DeleteIndex("sample");
}
// Create a new "sample" index with default settings
client.CreateIndex("sample", new IndexSettings());
// Index all documents
client.IndexMany<Document>(documents);
ViewBag.Message = "Reindexing all database is complete!";
return RedirectToAction("Index");
}
示例2: BlackListDataManager
public BlackListDataManager()
{
try
{
var elasticSearchUrl = ConfigurationManager.AppSettings["ElasticStoreConnection"];
var index = ConfigurationManager.AppSettings["EIndex_BlackList"];
_settings =
new ConnectionSettings(new Uri(elasticSearchUrl)).SetDefaultIndex(index).PluralizeTypeNames();
_client = new ElasticClient(_settings);
var isIndexExist = _client.IndexExists(i => i.Index(index));
if (!isIndexExist.Exists)
{
_client.CreateIndex(c => c.Index(index));
_settings.SetDefaultIndex(index);
_client = new ElasticClient(_settings);
}
var response =
_client.Map<BlockedUser>(
h =>
h.MapFromAttributes(10).Properties(p => p
.String(s => s.Name(i => i.ByEmail).Index(FieldIndexOption.NotAnalyzed))
.String(s => s.Name(i => i.ToEmail).Index(FieldIndexOption.NotAnalyzed))
));
IsServerError(response);
}
catch (Exception ex)
{
Logger.LogException(ex, _soruce, "BlackListDataManager", Severity.Critical);
throw;
}
}
示例3: GameDataManager
public GameDataManager()
{
try
{
var elasticSearchUrl = ConfigurationManager.AppSettings["ElasticStoreConnection"];
var index = ConfigurationManager.AppSettings["EIndex_Game"];
_settings =
new ConnectionSettings(new Uri(elasticSearchUrl)).SetDefaultIndex(index).PluralizeTypeNames();
_client = new ElasticClient(_settings);
var isIndexExist = _client.IndexExists(i => i.Index(index));
if (!isIndexExist.Exists)
{
_client.CreateIndex(c => c.Index(index));
_settings.SetDefaultIndex(index);
_client = new ElasticClient(_settings);
}
var response =
_client.Map<Game>(
h =>
h.Properties(p => p
.String(s => s.Name(i => i.GameId).Index(FieldIndexOption.NotAnalyzed))
.String(s => s.Name(i => i.Status).Index(FieldIndexOption.NotAnalyzed))
.String(s => s.Name(i => i.TurnOfPlayer).Index(FieldIndexOption.NotAnalyzed))
.Object<Winner>(o => o.Name(w => w.Winner).Properties(wp => wp.String(f => f.Name(l => l.FacebookId).Index(FieldIndexOption.NotAnalyzed)))
)));
IsServerError(response);
}
catch (Exception ex)
{
Logger.LogException(ex, _source, "GameDataManager", Severity.Critical);
throw;
}
}
示例4: GetClient
public IElasticClient GetClient(IElasticConnectionSettings settings)
{
if (settings == null) throw new ArgumentNullException("settings");
var connectionSettings = new ConnectionSettings(settings.Host, settings.Port);
connectionSettings.SetDefaultIndex(settings.IndexName);
return new ElasticClient(connectionSettings);
}
示例5: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
container.Register<IAutocompleteFinder, AutocompleteFinder>();
container.Register<IElasticClient>((ctr, param) =>
{
var connectionSettings = new ConnectionSettings(new Uri("http://172.31.170.182:9200/"));
connectionSettings.SetDefaultIndex("autocomplete");
return new ElasticClient(connectionSettings);
});
}
示例6: GetClient
protected ElasticClient GetClient()
{
if (_client == null)
{
var elasticSettings = new ConnectionSettings("127.0.0.1.", 9200);
elasticSettings.SetDefaultIndex(index);
_client = new ElasticClient(elasticSettings);
}
return _client;
}
示例7: EsClient
/// Constructor
public EsClient()
{
var node = new Uri(ElasticUri);
_settings = new ConnectionSettings(node);
_settings.SetDefaultIndex(ConfigurationManager.AppSettings["DefaultIndex"]);
_settings.MapDefaultTypeNames(m => m.Add(typeof(HadoopMetaDataModels), ConfigurationManager.AppSettings["DefaultIndexType"]));
Current = new ElasticClient(_settings);
Current.Map<HadoopMetaDataModels>(m => m
.MapFromAttributes());
}
示例8: CreateClient
public static IElasticClient CreateClient(IContainer container)
{
var configuration = ClientConfigurationSection.GetConfiguration();
var connectionSettings = new ConnectionSettings(
new Uri(configuration.ElasticSearchUrl)
);
ConfigureIdProperty(connectionSettings);
connectionSettings.SetJsonSerializerSettingsModifier(x => {
x.Converters = ContentIndexer.Instance.IndexingConventions.JsonConverters;
x.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
connectionSettings.SetDefaultTypeNameInferrer(x => typeof(IContent).IsAssignableFrom(x) ? Constants.EPiServerContentTypeName : null);
connectionSettings.SetDefaultIndex(container.GetInstance<IndexResolver>().ResolveIndex());
connectionSettings.ExposeRawResponse();
container.Configure(x => x.For<ConnectionSettings>().Use(connectionSettings));
return new ElasticClient(connectionSettings, null, new PreSerializationProccessor(connectionSettings));
}
示例9: ConfigureElasticClient
public void ConfigureElasticClient()
{
//var setting = new ConnectionSettings(new Uri("http://localhost:9200/"),Constants.INDEX_PERSON);
//setting.EnableTrace();
//setting.ExposeRawResponse();
//client = new ElasticClient(setting);
var node = new Uri(Constants.ELASTIC_SEARCH_URI);
var settings = new ConnectionSettings(node);
settings.SetDefaultIndex(Constants.INDEX_PERSON);
settings.MapDefaultTypeNames(m => m.Add(typeof(Person), (Constants.INDEX_PERSON)));
client = new ElasticClient(settings);
client.CreateIndex(ci => ci
.Index(Constants.INDEX_PERSON)
.AddMapping<Person>(m => m.MapFromAttributes()));
}
示例10: GetClientsBy
public List<ClientInformation> GetClientsBy(string name, bool? onlyPossiblyStolen)
{
ElasticClient esClient;
var settings = new ConnectionSettings(new Uri("http://localhost:9200"));
settings.SetDefaultIndex(INDEX);
esClient = new ElasticClient(settings);
//text is always in lowercase in ES
if (!string.IsNullOrEmpty(name))
name = name.ToLowerInvariant();
var result = esClient.Search<ClientInformation>(
sd => sd.Query( q=> q.Strict(false).Wildcard(t => t.Name,name))
.Filter(f =>
f.Strict(false).Term(t => t.PossiblyStolen, onlyPossiblyStolen))
);
return result.Documents.ToList();
}
开发者ID:mojamcpds,项目名称:CQRS-NServiceBus-EventStore-ElasticSearch,代码行数:22,代码来源:ClientInformationRepository.cs
示例11: Main
static void Main(string[] args)
{
var reader = new StreamReader("C:/data/logs/FritzLog.csv");
var csv = new CsvReader(reader);
csv.Parser.Configuration.Delimiter = ";";
csv.Configuration.HasHeaderRecord = true;
csv.Configuration.IgnoreHeaderWhiteSpace = true;
var records = csv.GetRecords<LogEntry>();
var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(node);
settings.SetDefaultIndex("phonelog");
var client = new ElasticClient(settings);
client.DeleteIndex("phonelog");
client.CreateIndex(ci => ci.Index("phonelog").AddMapping<LogEntry>(m => m.MapFromAttributes()));
foreach (var record in records)
{
var result = client.Index(record);
Console.WriteLine(record + ", Result: " + result);
}
}
示例12: AdventureLocationRepository
public AdventureLocationRepository()
{
var setting = new ConnectionSettings("office.mtctickets.com", 9200);
setting.SetDefaultIndex("pins");
client = new ElasticClient(setting);
}
示例13: Insert
internal bool Insert(ad_network obj)
{
var connectionSettings = new ConnectionSettings(MainVariables.conElasticSearch);
connectionSettings.SetDefaultIndex("ad_network");
var elasticClient = new ElasticClient(connectionSettings);
//var indexaaa = elasticClient.DeleteIndex("advertisement");
var index = elasticClient.Index(obj);
if (index.ServerError == null) return true;
else return false;
}
示例14: Index
private static void Index(DocumentModel document, String operation)
{
var uriString = ConfigurationManager.AppSettings["SEARCHBOX_URL"];
var searchBoxUri = new Uri(uriString);
var settings = new ConnectionSettings(searchBoxUri);
settings.SetDefaultIndex(indexName);
var client = new ElasticClient(settings);
if (!client.IndexExists(indexName).Exists)
{
// Create a new "sample" index with default settings
ICreateIndexRequest iCreateIndexReq = new CreateIndexRequest(indexName);
iCreateIndexReq.IndexSettings = new IndexSettings();
iCreateIndexReq.IndexSettings.NumberOfReplicas = 10;
//iCreateIndexReq.IndexSettings.Mappings = new List<RootObjectMapping>();
//RootObjectMapping rootObjectMapping = new RootObjectMapping();
//rootObjectMapping.AllFieldMapping()
//iCreateIndexReq.IndexSettings.Mappings.
//client.CreateIndex(iCreateIndexReq);
//client.CreateIndex(indexName,s=>s.)
var resCreate = client.CreateIndex(indexName, s => s.AddMapping<DocumentModel>(f => f.MapFromAttributes()).NumberOfReplicas(1).NumberOfShards(10));
//client.CreateIndex(indexName, new IndexSettings());
//client.create
}
if (operation.Equals("delete"))
{
//client.DeleteById(indexName, "documents", document.DocumentId);
IDeleteByQueryRequest iDeleteByQueryRequest = new DeleteByQueryRequest();
//IDeleteIndexRequest delReq = new DeleteIndexRequest(indexName);
//client.DeleteIndex()
//client.DeleteByQuery(new DeleteByQueryRequest())
client.Delete<DocumentModel>(f => f.Id(document.DocumentId).Index(indexName).Refresh());
//var response = this.Client.Delete<ElasticsearchProject>(f=>f.Id(newDocument.Id).Index(newIndex).Refresh());
}
else
{
//IIndexRequest<DocumentModel> indexRequest = IndexRequest<DocumentModel>();
//client.Index(i)
//client.Index(document, indexName, "documents", document.DocumentId);
//IndexDescriptor indexDesc = IndexDescriptor;
//IndexRequestParameters indexParameter = new IndexRequestParameters();
// indexParameter.Replication(1);
client.Index(document, i => i.Id(document.DocumentId).Index(indexName));
//client.Index();
//client.Index()
}
}
示例15: SelectAll
public List<ad_network> SelectAll()
{
List<ad_network> list = new List<ad_network>();
var connectionSettings = new ConnectionSettings(MainVariables.conElasticSearch);
connectionSettings.SetDefaultIndex("ad_network");
var elasticClient = new ElasticClient(connectionSettings);
var searchResults = elasticClient.Search<ad_network>(s => s.Query(q => q.MatchAll()));
list = searchResults.Documents.ToList();
return list;
}