Skip to content

No way to retrieve _id from TermVectorResponse #1484

Closed
@wewebber

Description

@wewebber

I can't see a way of retrieving the _id of a (multi-)term vector request from the NEST result, or therefore of matching vectors with documents in a multiterm request.

Consider the JSON query:

POST /xindex/xobject/_mtermvectors
{
     "ids" : ["b", "a", "c"],
     "parameters" : { "fields" : [ "text" ] }
}

This will give you a JSON result something like:

{
    "docs" : [
        {
            "_index" : "xindex",
            "_type" : "xobject",
            "_id" : "b",
            // ...
            "term_vectors" : {
                "text" : {
                    "terms": {
                        "cat" : { "term_freq" : 2 },
                        "dog" : { "term_freq" : 3 },
                        // ...
                    }
                }
            }
        }
        {
            // ...
            "_id": "c",
            // ...
        }
    ]
}

In NEST, this might look something like:

IMultiTermVectorResponse response = this.Client.MultiTermVectors<Xobject>(
        d => d.Ids(["b","a","c"]).Fields(m => m.Text));
IDictionary<string, TermVector> vectorsById = new Dictionary<string, TermVector>();
foreach (TermVectorResponse tvResponse in response.Documents)
{
    string docId = "HOW TO GET THIS?";;
    vectorsById.Add(docid, tvResponse.TermVectors["text"]);
}

There's no way that I can see how to get the "_id" value out of the TermVectorResponse object, nor from any related object. Nor are documents returned in the same order as the ids are specified in the query. So I can't see how to map from the requested document ID to the term vector for that document.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions