# Admin Such-Optimierung / default-search-configuration.js

**URL:** <https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397>\
**Category:** Administration\
**Tags:** administration, programming\
**Created:** [16. Mai 2022 um 10:17 UTC](https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397 "2022-05-16T10:17:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ansgar](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/ansgar/32/7871_2.png) [@ansgar](https://forum.shopware.com/u/ansgar)\
**Post date:** [16. Mai 2022 um 10:17 UTC](https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397/1 "2022-05-16T10:17:08Z")

</div>

Hallo,

wir haben ca. 400.000 Bestellungen in der `order` Tabelle. Die Suche im Admin erfolgt meist nach Bestellnummer, dauert aber meist über 1 Minute, weil im Hintergrund alle möglichen Felder mit durchsucht werden (Kunden-Adresse, Tracking-IDs etc.)  
Kann ich, um die Suche nach Bestellungen zu beschleunigen, die durchsuchten Felder reduzieren?  
Ich sehe hier eine Query-Konfiguration:

```
vendor/shopware/administration/Resources/app/administration/src/module/sw-order/default-search-configuration.js

```

Kann ich diese `default-search-configuration.js` per eigenem Plugin überschreiben, oder sonstwie diese Konfiguration ändern, ohne die Originaldatei zu verändern?

\*Edit: die .js Datei definiert wohl eher die Felder die am rechten Rand durch den Benutzer gefiltert werden können. Was ich meine ist wie man die Suche nach Text aus dem oberen Suchfeld optimieren kann.

---

<div class="post-metadata">

**Author:** ![Moorleiche](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Moorleiche](https://forum.shopware.com/u/Moorleiche)\
**Post date:** [16. Mai 2022 um 17:44 UTC](https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397/2 "2022-05-16T17:44:42Z")

</div>

Da würde ich mal im Slack Channel von Shopware fragen.

Mein Ansatz wäre:  
EntitySearchedEvent subscriben und den query auf die nötigen Felder beschränken. Der Query selbst hat aber keinen Titel gesetzt. Es ist nur die Entity bekannt und dass der Query bei mir aktuell 69 Felder hat.

---

<div class="post-metadata">

**Author:** ![ansgar](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/ansgar/32/7871_2.png) [@ansgar](https://forum.shopware.com/u/ansgar)\
**Post date:** [17. Mai 2022 um 12:57 UTC](https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397/3 "2022-05-17T12:57:52Z")

</div>

Danke, der Ansatz funktioniert schon mal!

- Im Subscriber auf den Entity-Namen „order“ einschränken
- dann die Filter der `$event->getCriteria()->getQueries()` prüfen
- aussortieren was ich nicht brauche

Muss einem nur klar sein dass man damit nicht nur die API ändert: /api/search/order  
sondern auch im Frontend auf solchen URLs eingreift:

- /checkout/order
- /checkout/finish

… was hier nicht gewünscht ist. Daher suche ich noch einen Weg um das auf /admin einzuschränken.

---

<div class="post-metadata">

**Author:** ![Aubrey](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@Aubrey](https://forum.shopware.com/u/Aubrey)\
**Post date:** [3. November 2022 um 23:31 UTC](https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397/4 "2022-11-03T23:31:40Z")

</div>

@ansgar If the translation is correct on what you want to do: Add order entity extension fields to the order overview search;

We solved the problem like this:

```auto
// <plugin>/src/Resources/app/administration/src/overrides/module/sw-order/index.js
import { searchRankingPoint } from 'src/app/service/search-ranking.service';

const { Module } = Shopware;

const module = Module.getModuleByEntityName('order');

if (module?.manifest?.defaultSearchConfiguration) {
  module.manifest.defaultSearchConfiguration = {
    ...module.manifest.defaultSearchConfiguration,
    extensions: {
      // In case some other plugin has already done this trick; we do not want to remove theirs.
      ...(module.manifest.defaultSearchConfiguration.extensions ?? {}),
      // Add our extension fields to the omnisearch
      someExtension: {
        someProperty: {
          _searchable: true,
          _score: searchRankingPoint.HIGH_SEARCH_RANKING,
        },
      }
    },
  };
}

```

This then of course needs to be imported by the plugin `main.js`.

> EDIT: No you want to remove things…  
> And so to remove things… you can just remove them from the found `module.manifest.defaultSearchConfiguration`

---

<div class="post-metadata">

**Author:** ![ansgar](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/ansgar/32/7871_2.png) [@ansgar](https://forum.shopware.com/u/ansgar)\
**Post date:** [20. Januar 2023 um 07:00 UTC](https://forum.shopware.com/t/admin-such-optimierung-default-search-configuration-js/94397/5 "2023-01-20T07:00:38Z")

</div>

Thanks for the hint, Aubrey.

Goal is to speed up the slow search in the admin area. Especially if you search for a specific order when the search phrase is an order number. This is a very common use case, so the potential for an enhancement is great.

I just found that v6.5 will index the order.product\_number column, so this is probably the best solution: [Shopware Issuetracker](https://issues.shopware.com/issues/NEXT-24510)
