According to the value in List, it is best to use springdata mongodb to query fuzzy query mongodb,.

  1. now the condition is that a List, such as type ["sh", "th"] / / is not the full value in the database type, but only has a prefix
  2. .
  3. according to this query, the following database shows that type contains sh and th prefixes, and the whole document
  4. the result should be 1, 2, 4 record (document) should be detected
  5. how to implement it, it"s best to use springdata mongdb, or other java methods

for example, the database has three record entries as follows:

{
    "_id": "5bcfe3367f0xxxxx02",
    "type": [
        "sh-adidas",
        "th-NB"
    ],
    "status": "active",
    "lastUpdateDate": "2018-10-25T17:27:41+08:00"
}
{
    "_id": "5bcfe3367f0xxxxx02",
    "type": [
        "bj-nike",
        "sh-adidas"
    ],
    "status": "active",
    "lastUpdateDate": "2018-10-25T17:27:41+08:00"
}
{
    "_id": "5bcfe3367f0xxxxx02",
    "type": [
        "bj-nike"
    ],
    "status": "active",
    "lastUpdateDate": "2018-10-25T17:27:41+08:00"
}
{
    "_id": "5bcfe3367f0xxxxx02",
    "type": [
        "bj-nike",
        "sh-adidas",
        "th-NB",
        "th-vans"
    ],
    "status": "active",
    "lastUpdateDate": "2018-10-25T17:27:41+08:00"
}

mongoSQL:

db.inventory.find({"$or":[{type:{"$regex":"sh"}},{type:{"$regex":"bj"}}]});

SpringData Mongo:

Query qury = query.orOperator(Criteria.where("type").regex("sh"),Criteria.where("type").regex("bj"));
mongoTemplate.find(qury,entityClass);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e49902-44d46.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e49902-44d46.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?