Skip to content

ftSearch does not handle null values and swaps the subsequent key value pairs in SearchResults output object. #59

@ankurgar

Description

@ankurgar

I am implementing ft.search command using lettuce mod in redis json. below is the raw query -

FT.SEARCH idx:accountproject '@siteId:[1 1] @status:{A} @premises:{ON}' RETURN 9 id accountId siteId addressAddress1 addressAddress2 addressCity addressStateProvince addressPostalCode addressCountry LIMIT 0 1

and it returns below response -

1) "4391"
2) "accpro:100"
3) 1) "id"
   2) "100"
   3) "accountId"
   4) "500"
   5) "siteId"
   6) "1"
   7) "addressAddress1"
   8) "6******"
   9) "addressAddress2"
   10) "null"
   11) "addressCity"
   12) "F******"
   13) "addressStateProvince"
   14) "FL"
   15) "addressPostalCode"
   16) "33351"
   17) "addressCountry"
   18) "null"

While I try to same via java lettuce library, then I get below response -

{id=100, accountId=500, siteId=1, addressAddress1=6*****, addressAddress2=addressCity, F********=addressStateProvince, FL=addressPostalCode, 33351=addressCountry}

Here addressAddress2 is having incorrect value, and the following keys.. It is happening because of mis handling of null values in lettuce library.

Below is my redis client setup -

    final RedisURIBuilder uriBuilder = new RedisURIBuilder()
        .host(host)
        .port(port)
        .password(password);
    RedisModulesClient redisModulesClient = RedisModulesClient.create(uriBuilder.build());
    redisModulesClient.setOptions(
        ClientOptions.builder()
            .timeoutOptions(
                TimeoutOptions.builder().timeoutCommands(true).fixedTimeout(commandTimeOut).build())
            .protocolVersion(ProtocolVersion.RESP2)
            .socketOptions(SocketOptions.builder().connectTimeout(connectionTimeOut).build())
            .build());

Redis Index -

FT.CREATE
    idx:accountproject ON JSON
        PREFIX 1 accpro:
    SCHEMA
        $.id AS id TAG
        $.accountId AS accountId NUMERIC SORTABLE
        $.siteId AS siteId NUMERIC SORTABLE
        $.status AS status TAG SORTABLE
        $.premises AS premises TAG SORTABLE
        $.accountType AS accountType TAG SORTABLE

        $.location.coordinates AS locationCoordinates NUMERIC
        $.location.type AS locationType TAG 
        $.address.address1 AS addressAddress1 TAG
        $.address.address2 AS addressAddress2 TAG
        $.address.city AS addressCity TAG
        $.address.stateProvince AS addressStateProvince TAG
        $.address.postalCode AS addressPostalCode TAG
        $.address.country AS addressCountry TAG

Lettuce mod version 4.1.0
Lettuce core version 6.3.2.RELEASE

Related stack over flow question - https://stackoverflow.com/questions/79058586/lettuce-mod-library-omitting-null-values-and-mis-aligning-key-value-pairs-for-ft

Please kindly help me in resolving this null handling issue in lettuce.

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