3

I would like to know how to add text type indexes in my ODM configuration by XML to solve this problem and search by name.

Thanks for everything.

Regards.

PD: I'm sorry for my English.

<document name="App\Document\Doc" db="db" collection="collection"
          repository-class="App\Repository\DocRepository">
    <id field-name="id" strategy="INCREMENT" type="int"/>
    <field field-name="code" name="code" type="string"/>
    <field field-name="name" name="name" type="string"/>
    <field field-name="type" name="type" type="string"/>

    <indexes>
        ???
    </indexes>
</document>

1 Answers1

0

After digging into some code I found this works:

<document name="App\Document\Doc" db="db" collection="collection"
          repository-class="App\Repository\DocRepository">
    <id field-name="id" strategy="INCREMENT" type="int"/>
    <field field-name="code" name="code" type="string"/>
    <field field-name="name" name="name" type="string"/>
    <field field-name="type" name="type" type="string"/>

    <indexes>
        <index name="fts">
            <key name="code" order="text" />
            <key name="name" order="text" />
            <key name="type" order="text" />
        </index>
    </indexes>
</document>

However the keyword order seems counterintuitive.

Janusz Slota
  • 383
  • 1
  • 3
  • 17