Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "XYZ": {
- "mappings": {
- "properties": {
- "customerInfo": {
- "properties": {
- "emailList": {
- "type": "text",
- "fields": {
- "keyword": {
- "type": "keyword"
- }
- }
- },
- "id": {
- "type": "text",
- "fields": {
- "completion": {
- "type": "completion",
- "analyzer": "standard",
- "preserve_separators": true,
- "preserve_position_increments": true,
- "max_input_length": 50,
- "contexts": [
- {
- "name": "mailboxIdStr",
- "type": "CATEGORY",
- "path": "mailboxIdStr"
- }
- ]
- },
- "keyword": {
- "type": "keyword"
- }
- }
- },
- "name": {
- "type": "text",
- "fields": {
- "completion": {
- "type": "completion",
- "analyzer": "simple",
- "preserve_separators": true,
- "preserve_position_increments": true,
- "max_input_length": 50,
- "contexts": [
- {
- "name": "mailboxIdStr",
- "type": "CATEGORY",
- "path": "mailboxIdStr"
- }
- ]
- },
- "keyword": {
- "type": "keyword"
- }
- },
- "fielddata": true
- }
- }
- }
- }
- }
- }
- }
- As per above mapping I'm making request something like this.
- {
- "suggest": {
- "subject_suggest": {
- "prefix": "t",
- "completion": {
- "field": "customerInfo.name.completion",
- "size": 3,
- "contexts": {
- "mailboxIdStr": [
- 770,
- 854,
- 901,
- 902
- ]
- }
- }
- }
- }
- }
- It gives me response something like this.
- {
- "suggest": {
- "subject_suggest": [
- {
- "text": "John",
- "offset": 0,
- "length": 1,
- "options": [
- {
- "text": "The G",
- "_index": "conversations",
- "_type": "_doc",
- "_id": "CxTc6W4Bk0d_pHk3pEIX",
- "_score": 1.0,
- "_source": {
- "customerInfo": {
- "id": "1",
- "name": "John",
- "emailList": "test@gmail.com"
- }
- }
- },
- {
- "text": "The G",
- "_index": "conversations",
- "_type": "_doc",
- "_id": "DhTc6W4Bk0d_pHk3pEIX",
- "_score": 1.0,
- "_source": {
- "customerInfo": {
- "id": "1",
- "name": "John",
- "emailList": "test@gmail.com"
- }
- }
- },
- {
- "text": "The G",
- "_index": "conversations",
- "_type": "_doc",
- "_id": "FRTc6W4Bk0d_pHk3pEIX",
- "_score": 1.0,
- "_source": {
- "customerInfo": {
- "id": "2",
- "name": "John",
- "emailList": "testing@google.com"
- }
- }
- }
- ]
- }
- ]
- }
- }
- In response i got dublicate records.
- It gives me 2 dublicate records --> id: 1 and name:John.
- In actual result name can be same but it should have unique id.
- My expected output is as per below.
- {
- "suggest": {
- "subject_suggest": [
- {
- "text": "John",
- "offset": 0,
- "length": 1,
- "options": [
- {
- "text": "The G",
- "_index": "testconversations",
- "_type": "_doc",
- "_id": "DhTc6W4Bk0d_pHk3pEIX",
- "_score": 1.0,
- "_source": {
- "customerInfo": {
- "id": "1",
- "name": "John",
- "emailList": "test@gmail.com"
- }
- }
- },
- {
- "text": "The G",
- "_index": "testconversations",
- "_type": "_doc",
- "_id": "FRTc6W4Bk0d_pHk3pEIX",
- "_score": 1.0,
- "_source": {
- "customerInfo": {
- "id": "2",
- "name": "John",
- "emailList": "testing@gmail.com"
- }
- }
- }
- ]
- }
- ]
- }
- }
- So i'm stuck here how to get this type of result.
Add Comment
Please, Sign In to add comment