There was a strange situation with the product’s multi condition query,
I found a different situation than expected when using collective_id and product_date to query products. The following is the query statement:
query products($first:Int,$queryStr: String ,$after: String,$last:Int,$before:String){
products(first: $first,reverse: true, sortKey: UPDATED_AT, query: $queryStr, after: $after,last:$last, before:$before) {
edges {
node {
id
title
productType
vendor
tags
}
}
pageInfo{
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}
I will list the query criteria in three situations:
1.When the condition is only collection-id, the query result is as follows:
variables: {"first":10,"queryStr":"collection_id:\"512040468785\" "}
result: {
"data": {
"products": {
"edges": [
{
"node": {
"id": "gid://shopify/Product/10255024587057",
"title": "Continuous Setting Mist",
"collections": {
"edges": [
{
"node": {
"id": "gid://shopify/Collection/494944092465",
"title": "Automated Collection"
}
},
{
"node": {
"id": "gid://shopify/Collection/512040468785",
"title": "10 and under"
}
},
{
"node": {
"id": "gid://shopify/Collection/512042828081",
"title": "15 and under"
}
}
]
},
"productType": "",
"vendor": "Morphe",
"tags": []
}
}
],
"pageInfo": {
"endCursor": "eyJsYXN0X2lkIjoxMDI1NTAyNDU4NzA1NywibGFzdF92YWx1ZSI6IjIwMjUtMDYtMTIgMDE6NTg6MjUuMDAwMDAwIn0=",
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "eyJsYXN0X2lkIjoxMDI1NTAyNDU4NzA1NywibGFzdF92YWx1ZSI6IjIwMjUtMDYtMTIgMDE6NTg6MjUuMDAwMDAwIn0="
}
}
}
}
2.When the condition is only productotype, the query result is as follows:
variables: {"first":10,"queryStr":"product_type:\"type0805\""}
result: {
"data": {
"products": {
"edges": [
{
"node": {
"id": "gid://shopify/Product/10307753574705",
"title": "Test product10 6",
"collections": {
"edges": [
{
"node": {
"id": "gid://shopify/Collection/494944092465",
"title": "Automated Collection"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945108273",
"title": "T-RELIEF"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945206577",
"title": "PAIN"
}
}
]
},
"productType": "type0805",
"vendor": "devstore-china",
"tags": [
"0827",
"ddd",
"test0805"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10380646154545",
"title": "icy sea (Copy) (Copy)",
"collections": {
"edges": []
},
"productType": "type0805",
"vendor": "vendor0805",
"tags": [
"test0805"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10380635242801",
"title": "icy sea (Copy)",
"collections": {
"edges": []
},
"productType": "type0805",
"vendor": "vendor0805",
"tags": [
"test0805"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10297947947313",
"title": "twilight rain - 6",
"collections": {
"edges": []
},
"productType": "type0805",
"vendor": "devstore-china",
"tags": [
"ddd",
"Winter"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10297947717937",
"title": "icy sea",
"collections": {
"edges": []
},
"productType": "type0805",
"vendor": "vendor0805",
"tags": [
"test0805"
]
}
}
],
"pageInfo": {
"endCursor": "eyJsYXN0X2lkIjoxMDI5Nzk0NzcxNzkzNywibGFzdF92YWx1ZSI6IjIwMjUtMDgtMDUgMTc6NTM6NDkuMDAwMDAwIn0=",
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "eyJsYXN0X2lkIjoxMDMwNzc1MzU3NDcwNSwibGFzdF92YWx1ZSI6IjIwMjUtMDgtMjcgMTc6NTc6MjUuMDAwMDAwIn0="
}
}
}
}
3.When two conditions are combined, an unexpected situation occurs:
variables: {"first":10,"queryStr":"collection_id:\"512040468785\" OR product_type:\"type0805\""}
result: {
"data": {
"products": {
"edges": [
{
"node": {
"id": "gid://shopify/Product/10307753574705",
"title": "Test product10 6",
"collections": {
"edges": [
{
"node": {
"id": "gid://shopify/Collection/494944092465",
"title": "Automated Collection"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945108273",
"title": "T-RELIEF"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945206577",
"title": "PAIN"
}
}
]
},
"productType": "type0805",
"vendor": "devstore-china",
"tags": [
"0827",
"ddd",
"test0805"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10307753574705",
"title": "Test product10 6",
"collections": {
"edges": [
{
"node": {
"id": "gid://shopify/Collection/494944092465",
"title": "Automated Collection"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945108273",
"title": "T-RELIEF"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945206577",
"title": "PAIN"
}
}
]
},
"productType": "type0805",
"vendor": "devstore-china",
"tags": [
"0827",
"ddd",
"test0805"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10307753574705",
"title": "Test product10 6",
"collections": {
"edges": [
{
"node": {
"id": "gid://shopify/Collection/494944092465",
"title": "Automated Collection"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945108273",
"title": "T-RELIEF"
}
},
{
"node": {
"id": "gid://shopify/Collection/494945206577",
"title": "PAIN"
}
}
]
},
"productType": "type0805",
"vendor": "devstore-china",
"tags": [
"0827",
"ddd",
"test0805"
]
}
},
{
"node": {
"id": "gid://shopify/Product/10255024587057",
"title": "Continuous Setting Mist",
"collections": {
"edges": [
{
"node": {
"id": "gid://shopify/Collection/494944092465",
"title": "Automated Collection"
}
},
{
"node": {
"id": "gid://shopify/Collection/512040468785",
"title": "10 and under"
}
},
{
"node": {
"id": "gid://shopify/Collection/512042828081",
"title": "15 and under"
}
}
]
},
"productType": "",
"vendor": "Morphe",
"tags": []
}
}
],
"pageInfo": {
"endCursor": "eyJsYXN0X2lkIjoxMDI1NTAyNDU4NzA1NywibGFzdF92YWx1ZSI6IjIwMjUtMDYtMTIgMDE6NTg6MjUuMDAwMDAwIn0=",
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "eyJsYXN0X2lkIjoxMDMwNzc1MzU3NDcwNSwibGFzdF92YWx1ZSI6IjIwMjUtMDgtMjcgMTc6NTc6MjUuMDAwMDAwIn0="
}
}
}
}
It can be seen that duplicate data appears in the third query result, with ‘Test product10 6’ appearing three times. I am not sure what caused this, can anyone answer this question?