mongodb-odm icon indicating copy to clipboard operation
mongodb-odm copied to clipboard

Document working with text indexes

Open alcaeus opened this issue 5 years ago • 4 comments

Feature Request

Q A
New Feature no
RFC no
BC Break no

Summary

The index section in the docs does not contain any information on how to work with text indexes. While the query builder docs have a section on text search (see https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/1.2/reference/query-builder-api.html#text-search), it would be beneficial to also document creating text indexes along with the various options that are possible for them.

alcaeus avatar Aug 20 '19 12:08 alcaeus

This just popped up on SO: https://stackoverflow.com/questions/61933036/error-text-index-required-for-text-query

malarzm avatar May 24 '20 10:05 malarzm

@alcaeus I faced with error about language. I use db version v4.4.0

I added index to my collection

/**
 * @MongoDB\Document(repositoryClass=AwinProductRepository::class)
 * @MongoDB\Index(keys={"product_name"="text"})
 */
class AwinProduct extends AbstractDocument
{
    /**
     * @MongoDB\Field(type="string")
     */
    protected $aw_deep_link;

    /**
     * @MongoDB\Field(type="string")
     */
    protected $product_name;

and then try to update schema

/var/www/symfony # php bin/console doctrine:mongodb:schema:update
Index build failed: 201968ff-ee54-456e-afc1-6ed742906343: Collection symfony.AwinProduct ( 71eb1888-9850-4799-889b-2d5908bcab46 ) :: caused by :: language override unsupported: 
/var/www/symfony # 

in native query I faced with the same problem

db.getCollection('AwinProduct').createIndex( { product_name: "text", aw_product_id: "text" } )

Index build failed: 024ff5ce-07fc-493f-be0f-bc21b8c28cfe: Collection symfony.AwinProduct ( 71eb1888-9850-4799-889b-2d5908bcab46 ) :: caused by :: language override unsupported:

hm, some advice ?

shubaivan avatar Aug 05 '20 21:08 shubaivan

This just popped up on SO: https://stackoverflow.com/questions/61933036/error-text-index-required-for-text-query

I've answered this question on SO, if you still need it.

nixilla avatar Dec 10 '21 12:12 nixilla

@nixilla cool! Would you mind contributing to our documentation as well?

malarzm avatar Dec 10 '21 20:12 malarzm