Is there a limit for the msearch?

i tried getting results from elastic_client.search and elastic_client.msearch and both returns different amount of results. and elastic_client.search returns the most accurate result

Your question lacks a fair bit of context unfortunately.

What version of Elasticsearch? What sort of queries are you running? What are the results you are seeing? What are you expecting? Please provide code, logs, responses etc.

based on these two sets of queries

def queryNCRate(unit_type):                                                       

    wyList = []
    ncList = []
    ncHits = []
    rateList = []

    # create request
    request = []

    for wy, nc in product(wy_request, nc_request):
        head = { 'index' : ES_INDEX }
        body = {
            'query': {
                'bool': {
                    'must': [
                        { 'match_phrase' : { 'text' : nc} },
                        { 'match_phrase' : { 'workyear' : wy} },
                        { 'match_phrase' : { 'unit_type' : unit_type} }
                    ]
                }
            }
        }

        request.extend([head, body])
    # print(request)
    # search through defined index with the query for nc for particular workyear
    nc_result = elastic_client.msearch(body=request)
    # print(nc_result)

    # returns amount of defined ncs for particular workyear
    nc_hits = len(nc_result["responses"][18]["hits"]["hits"])
    
    print(nc_hits)

and this

st = []
    ncList = []
    ncHits = []
    rateList = []

    for wy, nc in product(wy_request, nc_request):
            
        query_nc = {
            "query" : {
                "bool" : { 
                    "must" : [
                        { 
                            "match_phrase": { 
                                "text": nc
                            } 
                        },
                        { 
                            "match_phrase": {
                                "workyear": wy
                            }
                        },
                        {
                            "match_phrase": {
                                "unit_type": unit_type
                            }
                        }
                    ]
                }
            }
        }
        nc_result = elastic_client.search(index="test-index", body=query_nc, size=999) # searching thru the defined index with the query for NC for particular workyear
        # print(nc_result["hits"]["hits"])
        nc_hits = len(nc_result["hits"]["hits"]) # returns the amount of defined NCs for the particular workyear
        print(nc_hits)
        
        wyList.append(wy)
        ncList.append(nc[16:])
        ncHits.append(nc_hits)

        if (wyrsafDict.get(wy) != 0 ):
            nc_rate = nc_hits /  wyrsafDict.get(wy) # deriving the NC Rate
        else:
            nc_rate = 0
        # print("NCRate: ", nc_rate)
        rateList.append(nc_rate)

with the second query using elastic_client.search, i got 22 hits, which i doubled checked and confirmed that is the correct amount, but when i used elastic_client.msearch, i somehow gotten only 10 hits
and like those that i am supposed to get more than 10 hits, resulted in maximum of 10 hits

1 Like

For the search request you specify a size greater than 10. As this is not specified for the msearch you get the default 10 results.

1 Like

https://www.elastic.co/guide/en/elasticsearch/reference/7.8/search-multi-search.html has examples.

1 Like

thanks for the assistance!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.