This message was deleted.
# community-help
s
This message was deleted.
k
We don't support custom tokenization at the moment.
c
ok
what is the chs tokenizer? is this cappjieba? https://github.com/typesense/typesense/issues/267
k
We use the tokenizer in libicu
šŸ™Œ 1
šŸ™ 1
c
If, as mentioned in the text, the locale is not specified when creating the schema and self-tokenization is used, will this tokenization affect the embedding when using vector search? ``````
Segment both the indexed text and the search query string yourself is there example available
k
As long as you don't use locale but provide space separation in your data typesense will use those spaces for token boundaries. Then while searching use the pre_segmented_query flag so we will once again use spaces in the query to split tokens. That's all.
c
will this impact hybrid search?
k
Everything should work as expected. Can't think of a situation otherwise.
c
okay thanks will try it
šŸ‘ 1
so it looks the highlight mark will lost, because tokenlizer will drop many unnecessary word and save segmented to data, he UI itself implement the highlighting feature based on the query results?
k
Highlighter tries to find tokens in the query in the text. It might work. If it doesn't please post a small reproduceable example.
šŸ™Œ 1
c
ok thanks
hello i have tested with pre_segmented_query
i’ve found certain word doesn’t work with search? for example å­”ę˜Ž
i use other tool to cut words and save it to typesense without locale
still doesn’t match the result
Copy code
const fs = require('fs');
const _ = require('lodash')
const Typesense = require('typesense')

const { load, cut } = require('@node-rs/jieba');
const { log } = require('console');

load()

const txt = fs.readFileSync('./5.txt', 'utf8')

const databaseName123 = 'okaytest123'

const client = new Typesense.Client({
  'nodes': [{
    'host': 'localhost',
    'port': '8108',
    'protocol': 'http'
  }],
  'apiKey': 'xyz',
  'connectionTimeoutSeconds': 300
})

const schema = {
  'name': databaseName123,
  'fields': [
    { name: 'title', type: 'string', locale: 'zh' },
    { name: 'text', type: 'string' },

    {
      name: 'embedding',
      type: 'float[]',
      embed: {
        from: [
          'title',
        ],
        model_config: {
          model_name: 'ts/all-MiniLM-L12-v2'
        }
      }
    }
  ]
}

;(async function () {
  try {
    await client.collections(databaseName123).delete()
  } catch {

  }

  try {
    await client.collections().create(schema)
  } catch (ex) {
    console.log(ex)
  }

  const text = cut(txt).join(' ')

  fs.writeFileSync('./cut.txt', text)

  try {
    await client.collections(databaseName123).documents().import([
      { id: '1', title: txt, text },
    ])
  } catch (ex) {
    console.log(ex)
  }

  const resp = await client.collections(databaseName123).documents().search({
    q: `å­”ę˜Ž`,
    // query_by: 'embedding,title',
    query_by: 'text',
    // query_by: 'title',
    pre_segmented_query: true,
    // drop_tokens_threshold: 0, typo_tokens_threshold: 0, prefix: false
    // sort_by: '_vector_distance:desc'
  }).catch(console.log)

  // const result = _.map(resp.hits, (item) => {
  //   console.log(JSON.stringify(item.highlights, null, 2))
  //   // return {
  //   //   title: item.document.title,
  //   //   tags: item.document.tags,
  //   //   distance: item.vector_distance,
  //   // }
  // })

  console.log(JSON.stringify(resp, null, 2))
  // console.log(JSON.stringify(resp, null, 2))

  // console.log(await client.collections().retrieve())
} ())
k
Thanks for sharing the files. I'll check and get back to you in a day or so.
ā¤ļø 1
c
i think certain thing hide in 5.txt file break the search i’ve tried other raw chinese text file which is okay and random delete large paragraphs and keep some paragraphs, search works too, but undo the delete it broken
it looks locale english have the same issue if its a long text if you load this document and search the ā€œcrapthingsā€ it returns random result
k
it returns random result
The issue is that for very large documents we have to wrap the word offsets after 64,000 positions. The highlighting is not taking that into consideration. So you are getting correct results, but the wrong word is highlighted in the snippet because of the wrap around.
c
is this a bug? or there’s a settings for this
k
In general I don't recommend indexing such large docs. The correct practice would be to split it up into chunks and then doing a group by.
c
what is a best break point for such case? i’ve a document about 60w chars and i try to chunk it into 15w, and the search results looks okay
k
Maybe 10,000 words per document.
Can also be smaller. It depends on the use case and context.
c
Copy code
Should we compare and process highly similar texts outside Typesense, or should we use Typesense's built-in similarity feature and implement a deduplication mechanism?
Copy code
Is there a way to deduplicate after partitioning or chunk?
like for each document, do i search like this, and remove by score?
k
When you split a document into N sub documents, all documents can have a
parent_doc_id
field. Then during searching just do a
group_by=parent_doc_id