public ReturnTypeTests() { var settings = ElasticsearchConfiguration.Settings() .ExposeRawResponse(false); _clientThatDoesNotExpose = new ElasticClient(settings); }
public void Calling_Refresh_UsingHttpClientConnection_DoesNotThrow() { var settings = ElasticsearchConfiguration.Settings() .EnableCompressedResponses(true); var connection = new HttpClientConnection(settings); var client = new ElasticClient(settings, connection: connection); Assert.DoesNotThrow(() => client.Refresh()); Assert.DoesNotThrow(() => client.Get <ElasticsearchProject>(NestTestData.Data.First().Id)); Assert.DoesNotThrow(() => client.Ping()); }
public void IndexWithDashesAreNotStripped2() { var index = ElasticsearchConfiguration.NewUniqueIndexName() + "-dashes"; var x = this._client.CreateIndex(index); x.Acknowledged.Should().BeTrue(); var alias = ElasticsearchConfiguration.NewUniqueIndexName() + "-dashes-alias"; var aliasResult = this._client.Alias(a => a.Add(aa => aa.Index(index).Alias(alias))); aliasResult.IsValid.Should().BeTrue(); aliasResult.Acknowledged.Should().BeTrue(); var elasticsearchClient = new ElasticsearchClient(ElasticsearchConfiguration.Settings()); var dynamicResult = elasticsearchClient.IndicesGetAlias(alias); dynamicResult.Response.ContainsKey(index).Should().BeTrue(); }
public void Setup() { var client = new ElasticClient( //ElasticsearchConfiguration.Settings(hostOverride: new Uri("http://localhost:9200")) ElasticsearchConfiguration.Settings() ); try { IntegrationSetup.CreateTestIndex(client, ElasticsearchConfiguration.DefaultIndex); IntegrationSetup.CreateTestIndex(client, ElasticsearchConfiguration.DefaultIndex + "_clone"); IntegrationSetup.IndexDemoData(client); } catch (Exception) { throw; } }
public void AliasesWithDashesAreNotStripped() { //unique indexaname already contains dasshes but lets be sure about this //if the implementation ever changes var index = ElasticsearchConfiguration.NewUniqueIndexName() + "-dashes"; var x = this._client.CreateIndex(index); x.Acknowledged.Should().BeTrue(); var alias = ElasticsearchConfiguration.NewUniqueIndexName() + "-dashed-alias"; var aliasResult = this._client.Alias(a => a.Add(aa => aa.Index(index).Alias(alias))); aliasResult.IsValid.Should().BeTrue(); aliasResult.Acknowledged.Should().BeTrue(); var getIndicesResult = _client.GetIndicesPointingToAlias(alias); getIndicesResult.Should().NotBeEmpty(); var indexReturned = getIndicesResult.First(); indexReturned.Should().Be(index).And.Contain("-dashes"); var getAliasesResult = this._client.GetAliasesPointingToIndex(index); getAliasesResult.Should().NotBeEmpty().And.HaveCount(1); var aliasReturned = getAliasesResult.First().Name; aliasReturned.Should().Be(alias).And.Contain("-dashed-alias"); var elasticsearchClient = new ElasticsearchClient(ElasticsearchConfiguration.Settings()); var dynamicResult = elasticsearchClient.IndicesGetAlias(index); IDictionary <string, object> aliases = dynamicResult.Response[index].aliases; aliases.Count.Should().Be(1); var aliasDynamic = aliases.Keys.First(); aliasDynamic.Should().Be(alias); }
public void IndexUsingAnUrlAsIdUsingCustomUrlParameterInSettings() { var settings = ElasticsearchConfiguration.Settings().SetGlobalQueryStringParameters(new NameValueCollection { { "apiKey", "my-api-key" } }); var client = new ElasticClient(settings); var id = "http://www.skusuplier.com/products/123?affiliateId=23131#oopsIcopiedAnAnchor"; var newProduct = new Product { Id = id, Name = "Top Product" }; var response = client.Index(newProduct); var productInElasticsearch = client.Get <Product>(id); Assert.NotNull(productInElasticsearch); Assert.AreEqual(productInElasticsearch.Id, id); Assert.True(response.IsValid); }