Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hightlight stop working when perform infix search with fallback operation #1728

Open
SanthoshVeerabathiran opened this issue May 14, 2024 · 0 comments

Comments

@SanthoshVeerabathiran
Copy link

Description

Highlights are stop working, when i perform infix search with fallback operation in the search parameters

Steps to reproduce

1. My collection schema with infix enable for id_2 field:

{
    created_at: 1715666438,
    default_sorting_field: '',
    enable_nested_fields: true,
    fields: [
      {
        facet: false,
        index: true,
        infix: false,
        locale: '',
        name: 'id_7',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      },
      {
        facet: false,
        index: true,
        infix: false,
        locale: '',
        name: 'id_6',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      },
      {
        facet: false,
        index: true,
        infix: false,
        locale: '',
        name: 'id_8',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      },
      {
        facet: false,
        index: true,
        infix: false,
        locale: '',
        name: 'id_5',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      },
      {
        facet: false,
        index: true,
        infix: true,
        locale: '',
        name: 'id_2',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      },
      {
        facet: false,
        index: true,
        infix: false,
        locale: '',
        name: 'id_4',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      },
      {
        facet: false,
        index: true,
        infix: false,
        locale: '',
        name: 'id_3',
        optional: true,
        sort: false,
        stem: false,
        type: 'string'
      }
    ],
    name: 'sample',
    num_documents: 5,
    symbols_to_index: [],
    token_separators: []
} 

2. Sample Documents:

[
        {
            id_5: '82237e7b23c8d00c10',
            id_2: '822352dd4972780d06',
            id_3: '82237e7b98c8d01919',
            id_4: '23456',
            id_6: '947693749840',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        {
            id_5: '82237e7b23c8d00c18',
            id_2: '822352dd49727890b8',
            id_3: '82237e7b98c8d01919',
            id_4: '23457',
            id_6: '947693749840',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        {
            id_5: '82237e7b23c8d00c10',
            id_2: '822352dd4972785439',
            id_3: '82237e7b98c8d01919',
            id_4: '23765',
            id_6: '947693749840',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        {
            id_5: '82237e7b23c8d00c11',
            id_2: '822352dd497278v654',
            id_3: '82237e7b98c8d01919',
            id_4: '23987',
            id_6: '947693749840',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        {
            id_5: '82237e7b23c8d00c12',
            id_2: '822352dd497278b0b1',
            id_3: '82237e7b98c8d01919',
            id_4: '239432',
            id_6: '947693749842',
            id_7: '9834758374587',
            id_8: '822399482342'
        }
]

3. Search Parameters:

{ 
        q: '822352d5', 
        query_by: 'id_2', 
        infix: 'fallback', 
        per_page: 3 
}

Expected Behavior

When i search q = 822352d5 with infix = fallback , I expect highlights are working like below:

{
    facet_counts: [],
    found: 5,
    hits: [
        {
        document: {
            id: '4',
            id_1: '82237e7b23c8d00c12',
            id_2: '822352dd497278b0b1',
            id_3: '82237e7b98c8d01919',
            id_4: '239432',
            id_6: '947693749842',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        highlight: {
            id_2: {
            matched_tokens: [ '822352dd' ],
            snippet: '<mark>822352dd</mark>497278b0b1'
            }
        },
        highlights: [
            {
            field: 'id_2',
            matched_tokens: [ '822352dd' ],
            snippet: '<mark>822352dd</mark>497278b0b1'
            }
        ],
        text_match: 578730020285972600,
        text_match_info: {
            best_field_score: '1108041007104',
            best_field_weight: 15,
            fields_matched: 1,
            num_tokens_dropped: 0,
            score: '578730020285972601',
            tokens_matched: 1,
            typo_prefix_score: 3
        }
        },
        {
        document: {
            id: '3',
            id_1: '82237e7b23c8d00c11',
            id_2: '822352dd497278v654',
            id_3: '82237e7b98c8d01919',
            id_4: '23987',
            id_6: '947693749840',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        highlight: {
            id_2: {
            matched_tokens: [ '822352dd' ],
            snippet: '<mark>822352dd</mark>497278v654'
            }
        },
        highlights: [
            {
            field: 'id_2',
            matched_tokens: [ '822352dd' ],
            snippet: '<mark>822352dd</mark>497278v654'
            }
        ],
        text_match: 578730020285972600,
        text_match_info: {
            best_field_score: '1108041007104',
            best_field_weight: 15,
            fields_matched: 1,
            num_tokens_dropped: 0,
            score: '578730020285972601',
            tokens_matched: 1,
            typo_prefix_score: 3
        }
        },
        {
        document: {
            id: '2',
            id_2: '822352dd4972785439',
            id_3: '82237e7b98c8d01919',
            id_4: '23765',
            id_5: '82237e7b23c8d00c10',
            id_6: '947693749840',
            id_7: '9834758374587',
            id_8: '822399482342'
        },
        highlight: {
            id_2: {
            matched_tokens: [ '822352dd' ],
            snippet: '<mark>822352dd</mark>4972785439'
            }
        },
        highlights: [
            {
            field: 'id_2',
            matched_tokens: [ '822352dd' ],
            snippet: '<mark>822352dd</mark>4972785439'
            }
        ],
        text_match: 578730020285972600,
        text_match_info: {
            best_field_score: '1108041007104',
            best_field_weight: 15,
            fields_matched: 1,
            num_tokens_dropped: 0,
            score: '578730020285972601',
            tokens_matched: 1,
            typo_prefix_score: 3
        }
        }
    ],
    out_of: 5,
    page: 1,
    request_params: {
        collection_name: 'sample',
        first_q: '822352d5',
        per_page: 3,
        q: '822352d5'
    },
    search_cutoff: false,
    search_time_ms: 0
}

Actual Behavior

But, highlights are empty

{
        facet_counts: [],
        found: 5,
        hits: [
            {
            document: {
                id: '4',
                id_1: '82237e7b23c8d00c12',
                id_2: '822352dd497278b0b1',
                id_3: '82237e7b98c8d01919',
                id_4: '239432',
                id_6: '947693749842',
                id_7: '9834758374587',
                id_8: '822399482342'
            },
            highlight: {},
            highlights: [],
            text_match: 578730020285972600,
            text_match_info: {
                best_field_score: '1108041007104',
                best_field_weight: 15,
                fields_matched: 1,
                num_tokens_dropped: 0,
                score: '578730020285972601',
                tokens_matched: 1,
                typo_prefix_score: 3
            }
            },
            {
            document: {
                id: '3',
                id_1: '82237e7b23c8d00c11',
                id_2: '822352dd497278v654',
                id_3: '82237e7b98c8d01919',
                id_4: '23987',
                id_6: '947693749840',
                id_7: '9834758374587',
                id_8: '822399482342'
            },
            highlight: {},
            highlights: [],
            text_match: 578730020285972600,
            text_match_info: {
                best_field_score: '1108041007104',
                best_field_weight: 15,
                fields_matched: 1,
                num_tokens_dropped: 0,
                score: '578730020285972601',
                tokens_matched: 1,
                typo_prefix_score: 3
            }
            },
            {
            document: {
                id: '2',
                id_2: '822352dd4972785439',
                id_3: '82237e7b98c8d01919',
                id_4: '23765',
                id_5: '82237e7b23c8d00c10',
                id_6: '947693749840',
                id_7: '9834758374587',
                id_8: '822399482342'
            },
            highlight: {},
            highlights: [],
            text_match: 578730020285972600,
            text_match_info: {
                best_field_score: '1108041007104',
                best_field_weight: 15,
                fields_matched: 1,
                num_tokens_dropped: 0,
                score: '578730020285972601',
                tokens_matched: 1,
                typo_prefix_score: 3
            }
            }
        ],
        out_of: 5,
        page: 1,
        request_params: {
            collection_name: 'sample',
            first_q: '822352d5',
            per_page: 3,
            q: '822352d5'
        },
        search_cutoff: false,
        search_time_ms: 0
}

Metadata

Typesense Version: 26.0

OS: Mac OS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant