Hi @Sean_Story
Based on your more recent response, it sounds like you have a single index, with two documents. One of those documents shows up in your search results, the other does not. Is this correct? - Yes, Correct.
I have used only one index which has mapping mentioned below.
{
"mappings": {
"properties": {
"DocID": {
"type": "integer"
},
"Number": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"content": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"contentList": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"documentID": {
"type": "integer"
},
"documentName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"documentSource": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"documentURL": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"iD": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
Document which I have inserted
{
"_index": "esdocument_dev",
"_id": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq28",
"_score": 1,
"_source": {
"iD": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq28",
"DocID": 1111,
"documentName": "Upload Document",
"content": "Page :1\r\nDineshraj elastic document 18-03-2024\n\r\n",
"documentURL": "Upload Document.pdf",
"Number": "1111-0000",
"Name": "TEST ES",
"documentSource": "OTHER_DOCUMENT",
"documentID": 7
},
{
"_index": "esdocument_dev",
"_id": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq29",
"_score": 1,
"_source": {
"iD": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq29",
"DocID": 1111,
"documentName": "Upload Document",
"content": "Page :1\r\nDineshraj elastic document 18-03-2024\n\r\n",
"documentURL": "Upload Document.pdf",
"Number": "1111-0000",
"Name": "TEST ES",
"documentSource": "OTHER_DOCUMENT",
"documentID": 7
}
Curl command Query :
curl -X POST "https://development.com/elastic/esdocument_dev/_search" -u elastic -H 'Content-Type: application/json' -d '{
"query": {
"match_phrase": {
"content": "Dineshraj"
}
}
}'
For the above query, I'm getting both document as result below.
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 0.6533776,
"hits": [
{
"_index": "esdocument_dev",
"_id": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq28",
"_score": 1,
"_source": {
"iD": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq28",
"DocID": 1111,
"documentName": "Upload Document",
"content": "Page :1\r\nDineshraj elastic document 18-03-2024\n\r\n",
"documentURL": "Upload Document.pdf",
"Number": "1111-0000",
"Name": "TEST ES",
"documentSource": "OTHER_DOCUMENT",
"documentID": 7
}
},
{
"_index": "esdocument_dev",
"_id": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq29",
"_score": 1,
"_source": {
"iD": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq29",
"DocID": 1111,
"documentName": "Upload Document",
"content": "Page :1\r\nDineshraj elastic document 18-03-2024\n\r\n",
"documentURL": "Upload Document.pdf",
"Number": "1111-0000",
"Name": "TEST ES",
"documentSource": "OTHER_DOCUMENT",
"documentID": 7
}
}
]
}
}
I have a specific scenario where I'm querying Elasticsearch for documents based on the content field using the "match_phrase" operator with the text "Content":"Dineshraj". When I perform this query using a curl command, I'm getting both expected documents as results. However, when I execute the same query using the C# NEST library,
I'm only receiving one document as a result("_id": "qqqqqqqqq85-159a-qqqq-a1cc-qqqqqq29"
).
string searchKey = "Dineshraj";
var searchResponse = ElasticConnectionString.EsClient().Search<DocumentMetadata>(s => s
.From(from)
.Size(size)
.Index("esdocument_dev")
.Query(q => q
.MatchPhrase(m => m
.Field(f => f.Content)
.Query(searchKey)
)
)
);
I would appreciate your assistance in resolving this discrepancy. Could you please investigate why I'm not getting both documents in the C# NEST library search response? If there are any known issues or solutions related to the C# library, please redirect me to the relevant team or resources.