Alternative to PropertyPathMarker in NEST elasticsearch client library - elasticsearch

Im just kick starting my project to migrate elasticsearch from 1.7 to 7.x. As part this, changing my client library NEST to latest version.
Im extensively using PropertyPathMaker class in query generation logic. I can't seem to find what is that I need to use in latest version of NEST.
Can any of you help on this.
Below is the sample code i have problem with.
List<KeyValuePair<PropertyPathMarker, ISort>> BuildSortDetails(Dictionary<string, string> sortDetails,
SortOrder defaultSortOrder,
bool IsCaseInsensitive = false,
Dictionary<string, ListedBoolFilterContainers> nestedFilterDetails = null,
bool preserveSortOrderValue = false);

Field replaces PropertyPathMarker in NEST 2.x onwards.

Related

DeleteRequest example with elastic 8.3.0 java api client

I need examples for DeleteRequest with respect to ES 8.3.0 Java Api client.
I am looking for code reference where I want to delete one particular document by passing index name and the condition to delete the document.
I have found only Java High Level Rest Client(Deprecated in 7.15.0), and
Transport Client(Deprecated in 7.0.0).
You can use below code for delete specific document using id:
DeleteRequest request = DeleteRequest.of(d -> d.index("index_name").id("doc_id"));
DeleteResponse response = esClient.delete(request);
If you want to do DeleteByQuery then you can use below code (it will delete document where country is india):
DeleteByQueryRequest dbyquery = DeleteByQueryRequest
.of(fn -> fn.query(TermQuery.of(tq -> tq.field("country").value("india"))._toQuery()).index("index_name"));
DeleteByQueryResponse dqr = esClient.deleteByQuery(dbyquery);
There is no details document available for above. You can see open github issue for same here

ElasticSearch: Java API from 2.x to 5.x issues

I'm changing from ES 2.x java API to 5.x.
In 2.x I was used to do that in order to create an alias:
AliasAction action = new AliasAction(AliasAction.Type.ADD)
.alias(username)
.index(ElasticsearchRepository.ELASTICSEARCH_INDEX)
.searchRouting(username)
.indexRouting(username)
.filter(QueryBuilders.termQuery("user", username));
request = request.addAliasAction(action);
I0ve tried to figure out how to move that on 5.x. Nevertheless, I don't quite understand how to get that.
Any ideas?
From what I see here : https://www.javadoc.io/doc/org.elasticsearch/elasticsearch/5.0.0
It seems like they changed the way to attribute the alias to something like this :
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.addAliasAction(IndicesAliasesRequest.AliasActions.add()
.alias("TheAliasToAdd")
.index("TheIndexToAddTheAliasTo"));
client.admin().indices().aliases(indicesAliasesRequest);

elasticsearch term query with string value containing :(colon)

I am trying to execute a term query with value being a string which has colon in it. It works fine with the sense plugin.
GET XX/XX/_search
{
"query": {
"term" : { "XX.XX" : "7:140453136:T" }
}
}
But the same term query doesnt work with java API.
SearchRequestBuilder response = client.prepareSearch(indexName);
response.setTypes(indexType);
response.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
response.setQuery(QueryBuilders.termQuery("XX.XX", "7:140453136:T"));
response.setFrom(0).setSize(60).setExplain(true);
SearchResponse matchallResponse = response.execute().actionGet()
error:
TransportSerializationException[Failed to deserialize response of type [org.elasticsearch.action.search.SearchResponse]]
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.codecs.lucene50.Lucene50DocValuesFormat
in my mapping i had set this field to be not analyzed. so i am sure elasticsearch is not tokenizing it.
2.I am using ES 2.1.1
I see that there is already a question on this. But the solution posted there dosent solve my problem.
I had the latest lucene core libraries in my classpath which doesnt have Lucene50DocValuesFormat. I replaced the lucene core with 5.3.1 and everything works fine now. Dont use lucene core >5.3.1 with ES 2.1.1 is the solution for this problem. Thanks everyone! Hope this helps!

Object doesn't get updated after calling SaveAsync on Parse Unity 1.6.2

I have a column ("DataDict") storing type of Dictionary (let say the variable name is call "dataDict")
Recently I've updated to Parse Unity 1.6.2 and I found out that whenever I make an update to dataDict, it doesn't get updated to the server.
For example:
Dictionary<string, object> dict = ParseUser.CurrentUser["DataDict"] as Dictionary<string, object>;
dict["name"] = "something new";
// after I call ParseUser.CurrentUser.SaveAsync()
// the server should have updated the dictionary
// but it's no longer working as what I expected after I've updated to Parse 1.6.2
Does anyone know what's going on?
I noticed one of the keypoint that listed in the changelogs:
Removed 'mutable containers' functionality, significantly enhances performance.
Does this affected my codes? How should I fix it?
I've solved this by calling
ParseUser.CurrentUser["DataDict"] = dict;

Does NEST support updating index analysis?

As written in the elasticSearch documentation here, it's possible to define a new analysis for an index (I tried and it worked fine).
I was wondering if it was possible to perform the same thing with NEST?
I tried this:
ElasticClient.CloseIndex("myindex");
IndexSettings ndxSettings = ElasticClient.GetIndexSettings("myindex").Settings;
ndxSettings.Analysis.Analyzers.Add("snbowball", new SnowballAnalyzer());
var r = ElasticClient.UpdateSettings("myindex", ndxSettings);
ElasticClient.OpenIndex("myindex");
No error but nothing has changed.
When I try to see if the analyser has been added:
var getResponse = ElasticClient.GetIndexSettings("myindex");
getResponse.Settings.Analysis.Analyzers contains nothing.
You're doing the right thing, but analysis settings currently aren't on the UpdateWhiteList in NEST:
https://github.com/Mpdreamz/NEST/blob/master/src/Nest/Domain/Settings/IndexSettings.cs

Resources