logo
down
shadow

ElasticSearch parent/child on different indexes


ElasticSearch parent/child on different indexes

Content Index :

ElasticSearch parent/child on different indexes
Tag : elasticsearch , By : user98832
Date : November 29 2020, 01:01 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Using Elasticsearch.Net/NEST to search parent documents based on child attributes, where parent/child documents are stor


Tag : .net , By : littlefuzz
Date : March 29 2020, 07:55 AM
it helps some times Here's a small snippet where the address is the parent
EDIT: Create the index:
var indicesOperationResponse = _client.CreateIndex(ci => ci.Index("test")
            .AddMapping<Address>(m => m.MapFromAttributes())
            .AddMapping<Person>(m => m.MapFromAttributes().SetParent<Address>()));
var bulkResponse = _client.Bulk(b => b
            .Index<Address>(bd => bd.Object(new Address { Name = "Tel Aviv", Id = 1 }).Index("test"))
            .Index<Person>(bd => bd.Index("test").Object(new Person {Id = 5, Address = 1, Name = "Me"}).Parent(1)));
var searchResponse = _client.Search<Person>(s => s
        .Query(q=>q.MatchAll())
        .Filter(q => q
            .HasParent<Address>(c => c
                .Query(cq => cq.Match(m=>m.OnField(t => t.Name).Query("Tel Aviv"))))));

ElasticSearch: How can I get all child objects of different types using parent/child inner hits


Tag : elasticsearch , By : mylonov
Date : March 29 2020, 07:55 AM
help you fix your problem You can combine multiple has_child queries with inner_hits using a bool query. For example, if you wanted to find all the parents that had either a "ChildA" or a "ChildB" and then return all the children that they have (whether ChildA or ChildB or both), you could do something like this:
"query": {
  "bool": {
    "should": [
      {
        "has_child": {
          "type": "ChildA",
          "query": {
            "match_all": {}
          },
          "inner_hits": {}
        }
      },
      {
        "has_child": {
          "type": "ChildB",
          "query": {
            "match_all": {}
          },
          "inner_hits": {}
        }
      }
    ]
  }
}

Elasticsearch parent child shout return parent instead of child


Tag : elasticsearch , By : Tamizhvendan
Date : March 29 2020, 07:55 AM
Hope that helps your answer is not exactly what I was looking for but i gave my the right direction.
I have to query the parent type instead of the whole index. So this is my solution which is working like expected.
{
  "query": {
    "bool": {
      "should": [
        {
          "has_child": {
            "type": "answers",
            "query": {
              "query_string": {
                "query": "SearchWord"
              }
            }
          }
        },
        { 
            "query_string" : {
                "query": "SearchWord" 
            } 
        }
      ]
    }
  },
  "size": 1
}

ElasticSearch set parent for child object using ElasticSearch NEST .NET library


Tag : chash , By : sep
Date : March 29 2020, 07:55 AM
With these it helps The issue was that I was unable to map the parent-child documents properly .. we can map them by creating index with predefined mapping or we can update the mapping
Create Index
private ElasticLowLevelClient client = new ElasticLowLevelClient();    
private CreateIndexDescriptor descriptor = new CreateIndexDescriptor("myindex")
              .Mappings(ms => ms
              .Map<Person>("person", m => m.AutoMap())
              .Map<Skill>("personskills", m => m.AutoMap().Parent("person"))
          );        

public void CreatePerson(Person person)
{
    client.CreateIndex(descriptor); //I am creating it here but one can create it in the class where we will create ElasticClient
    var parentResponse = client.Index(person, i => i.Index("myindex").Type("person").Id(person.PersonId));
    foreach (var skill in person.Skills)
    {
       var skillResponse = client.Index(skill, i => i.Index("myindex").Type("personskills").Parent(person.PersonId.ToString()).Id(skill.SkillId)); //here I am getting error
    }
}
public void CreatePerson(Person person)
        {
 client.Map<Skill>(m => m
                                 .Parent("person").Index("myindex")); //this will put the default mapping of default index
var parentResponse = client.Index(person, i => i.Index("myindex").Type("person").Id(person.PersonId));
    foreach (var skill in person.Skills)
    {
       var skillResponse = client.Index(skill, i => i.Index("myindex").Type("skill").Parent(person.PersonId.ToString()).Id(skill.SkillId)); //here I am getting error
    }
}

Parent child relationship in ElasticSearch - search for a sentence in all the child docs combined


Tag : elasticsearch , By : Sonal
Date : March 29 2020, 07:55 AM
I hope this helps you . This can be done. You were close just a small mistake in the query.
In your child query, you are performing a bool with two must/should. Therefore, your query is: Give me all documents such that they have a child such that the child has both (or 'one of the' in case of should) the terms "best" and "location".
GET message_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "has_child": {
            "type": "feedback",
            "query": {
              "term": {
                "feedback": "best"
              }
            }
          }
        },
        {
          "has_child": {
            "type": "feedback",
            "query": {
              "term": {
                "feedback": "location"
              }
            }
          }
        }
      ]
    }
  }
}
Related Posts Related QUESTIONS :
  • Kibana and the _source field, Elastic Version 6.7
  • Delete all documents using javascript sdk?
  • Elasticsearch auto-complete not working correctly
  • In ElasticSearch 7+ how do you search all text fields?
  • Elasticsearch alias type to reference multi fields
  • Combining nested query get illegal_state_exception failed to find nested object under path
  • Is there any default way in elasticsearch to save the searches
  • Kibana Dashboard instead of my application dashboard
  • How to _reindex elasticsearch data to new mapping (from flat fields to objects)?
  • PUT vs POST when adding documents in elastic search
  • How to get definition of index alias?
  • Elasticsearch: Constant Data Field Type
  • Is searching dynamic (webpage) content with Elasticsearch possible?
  • ElasticSearch check if subset of word exists
  • Elasticsearch 2.4 search filter: mix term with regexp
  • Elasticsearch range query not working as expected
  • fastest way to tell if a term exists in the index or not
  • elasticsearch aggregation fields with text type mapping
  • How to increase the return result for the agg result list
  • Count of unique aggregration doc_count in ElasticSearch
  • ElasticSearch 6.x / 7.x - Index design
  • Unable to start ElasticSearch in my machine, StartupException is occuring while executing elasticsearch.bat
  • How to secure elasticsearch API's
  • Count Aggregation on filtered nested object giving incorrect result
  • elasticsearch facet nested aggregation
  • Histogram is not starting at the right min even filter added
  • Finding the set "max_result_window" for Elastic Search index?
  • How to enable TLS in Elasticsearch non-interactively?
  • elasticsearch match query returns empty results for nested fields
  • Elasticsearch 7.3 homebrew
  • Elasticsearch: How to optimize the source parameter in a script function?
  • Host name incorrect for logstash monitoring in Kibana
  • Elasticsearch: Unable to order results using script_score
  • Sonarqube analysis failing for huge code base - None of the configured nodes were available
  • Is is possible to term query with asciifolding?
  • Specify size for each subquery in Elasticsearch
  • How to extract and visualize values from a log entry in OpenShift EFK stack
  • Elasticsearch entity centric indexing
  • how do i split message into 2 properties based on one of 2 tokens?
  • How does ElasticSearch handle an index with 230m entries?
  • Elasticsearch bulk update query?
  • error while creating a mapping for document type under an index in elastic search
  • how can I query last month data in elasticsearch
  • Monitoring ElasticSearch with Grafana
  • German vs. German2 in ElasticSearch's snowball filter
  • Upserts with a script gives me a null pointer exception
  • ElasticSearch: Sort Aggregations by Filtered Average
  • Elasticsearch: How to query an array field using OR condition?
  • Match query doesn't return the result
  • Control number of buckets created in an aggregation
  • Elasticsearch: How to write an 'OR' clause in filter context?
  • what is settings in elastic search
  • Query regarding functionScoreQuery of elastic-builder npm for elasticsearch
  • Terms Aggregation excluding last vowels using Spanish analyze - Elasticsearch 6.4
  • match_phrase_prefix query not working with nested aggregation
  • what is the least version of kibana that supports painless language
  • How to grok a pipe-delimited string in a log line
  • how to convert elastic query aggregate filter into nest query in .Net core
  • Really huge query or optimizing an elasticsearch update
  • Getting error on Elastic Search query [ImageURL] query malformed, no start_object after query name
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com