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

Filters not working on channels with multiple entry types? #15

Closed
sonoflee opened this issue Nov 23, 2021 · 9 comments
Closed

Filters not working on channels with multiple entry types? #15

sonoflee opened this issue Nov 23, 2021 · 9 comments

Comments

@sonoflee
Copy link

I can't seem to apply omnisearch filters on Channels that have different Entry Types. Clicking the "+ Filter" button just brings up a search field ("Search Attributes") that is unresponsive. In the channels I'm testing this on, the different entry types do have different fields.

in console, I see the error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
[site url]/actions/omnisearch/fields?elementType=craft\elements\Entry&source=section:ef7c591c-185e-444f-b322-66ac110e58b0

@pohnean
Copy link
Collaborator

pohnean commented Nov 23, 2021 via email

@sonoflee
Copy link
Author

Please let me know if you need additional information, and thanks for the quick reply!

GET https://[site url]/actions/omnisearch/fields?elementType=craft\elements\Entry&source=section:ef7c591c-185e-444f-b322-66ac110e58b0 


PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'level' in 'field list' in /app/vendor/yiisoft/yii2/db/Command.php:1302
Stack trace:
#0 /app/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /app/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT `element...')
#2 /app/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /app/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /app/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /app/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1619): craft\db\Query->all(NULL)
#6 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(379): craft\elements\db\ElementQuery->all()
#7 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(337): bitmatrix\omnisearch\fields\BaseFields->getEntriesListData(Array)
#8 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(178): bitmatrix\omnisearch\fields\BaseFields->getRelationListItems(Object(craft\fields\Entries))
#9 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(155): bitmatrix\omnisearch\fields\BaseFields->createFieldConfig(Object(craft\fields\Entries), '')
#10 /app/vendor/bitmatrix/craft-omnisearch/src/fields/EntryFields.php(82): bitmatrix\omnisearch\fields\BaseFields->getCustomFieldsForElement(Object(craft\elements\Entry))
#11 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(98): bitmatrix\omnisearch\fields\EntryFields->customFields(Object(craft\elements\Entry), 'section:ef7c591...')
#12 /app/vendor/bitmatrix/craft-omnisearch/src/OmniSearch.php(126): bitmatrix\omnisearch\fields\BaseFields->getFields('section:ef7c591...')
#13 [internal function]: bitmatrix\omnisearch\OmniSearch->bitmatrix\omnisearch\{closure}(Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#14 /app/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#15 /app/vendor/yiisoft/yii2/base/Component.php(637): yii\base\Event::trigger('bitmatrix\\omnis...', 'defineFields', Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#16 /app/vendor/bitmatrix/craft-omnisearch/src/controllers/FieldsController.php(39): yii\base\Component->trigger('defineFields', Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#17 [internal function]: bitmatrix\omnisearch\controllers\FieldsController->actionIndex('craft\\elements\\...', 'section:ef7c591...')
#18 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#19 /app/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#20 /app/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('', Array)
#21 /app/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('omnisearch/fiel...', Array)
#22 /app/vendor/craftcms/cms/src/web/Application.php(596): craft\web\Application->runAction('omnisearch/fiel...', Array)
#23 /app/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#24 /app/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#25 /app/web/index.php(21): yii\base\Application->run()
#26 {main}

Next yii\db\Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'level' in 'field list'
The SQL being executed was: SELECT `elements`.`id` AS `value`, `title` AS `label`, COALESCE(level, 1) AS `level`
FROM (SELECT `elements`.`id` AS `elementsId`, `elements_sites`.`id` AS `elementsSitesId`, `content`.`id` AS `contentId`
FROM `elements` `elements`
INNER JOIN `entries` `entries` ON `entries`.`id` = `elements`.`id`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`elementId` = `elements`.`id`
INNER JOIN `content` `content` ON `content`.`elementId` = `elements`.`id`
WHERE (`entries`.`sectionId`='9') AND (`elements`.`archived`=FALSE) AND (((`elements`.`enabled`=TRUE) AND (`elements_sites`.`enabled`=TRUE)) AND (`entries`.`postDate` <= '2021-11-24 15:31:12') AND ((`entries`.`expiryDate` IS NULL) OR (`entries`.`expiryDate` > '2021-11-24 15:31:12'))) AND (`elements`.`dateDeleted` IS NULL) AND (`elements`.`draftId` IS NULL) AND (`elements`.`revisionId` IS NULL)
ORDER BY `entries`.`postDate` DESC) `subquery`
INNER JOIN `entries` `entries` ON `entries`.`id` = `subquery`.`elementsId`
INNER JOIN `elements` `elements` ON `elements`.`id` = `subquery`.`elementsId`
INNER JOIN `elements_sites` `elements_sites` ON `elements_sites`.`id` = `subquery`.`elementsSitesId`
INNER JOIN `content` `content` ON `content`.`id` = `subquery`.`contentId`
ORDER BY `entries`.`postDate` DESC in /app/vendor/yiisoft/yii2/db/Schema.php:678
Stack trace:
#0 /app/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT `element...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT `element...')
#2 /app/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /app/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /app/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /app/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1619): craft\db\Query->all(NULL)
#6 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(379): craft\elements\db\ElementQuery->all()
#7 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(337): bitmatrix\omnisearch\fields\BaseFields->getEntriesListData(Array)
#8 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(178): bitmatrix\omnisearch\fields\BaseFields->getRelationListItems(Object(craft\fields\Entries))
#9 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(155): bitmatrix\omnisearch\fields\BaseFields->createFieldConfig(Object(craft\fields\Entries), '')
#10 /app/vendor/bitmatrix/craft-omnisearch/src/fields/EntryFields.php(82): bitmatrix\omnisearch\fields\BaseFields->getCustomFieldsForElement(Object(craft\elements\Entry))
#11 /app/vendor/bitmatrix/craft-omnisearch/src/fields/BaseFields.php(98): bitmatrix\omnisearch\fields\EntryFields->customFields(Object(craft\elements\Entry), 'section:ef7c591...')
#12 /app/vendor/bitmatrix/craft-omnisearch/src/OmniSearch.php(126): bitmatrix\omnisearch\fields\BaseFields->getFields('section:ef7c591...')
#13 [internal function]: bitmatrix\omnisearch\OmniSearch->bitmatrix\omnisearch\{closure}(Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#14 /app/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#15 /app/vendor/yiisoft/yii2/base/Component.php(637): yii\base\Event::trigger('bitmatrix\\omnis...', 'defineFields', Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#16 /app/vendor/bitmatrix/craft-omnisearch/src/controllers/FieldsController.php(39): yii\base\Component->trigger('defineFields', Object(bitmatrix\omnisearch\fields\DefineFieldsEvent))
#17 [internal function]: bitmatrix\omnisearch\controllers\FieldsController->actionIndex('craft\\elements\\...', 'section:ef7c591...')
#18 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#19 /app/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#20 /app/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('', Array)
#21 /app/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('omnisearch/fiel...', Array)
#22 /app/vendor/craftcms/cms/src/web/Application.php(596): craft\web\Application->runAction('omnisearch/fiel...', Array)
#23 /app/vendor/craftcms/cms/src/web/Application.php(266): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#24 /app/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#25 /app/web/index.php(21): yii\base\Application->run()
#26 {main}
Additional Information:
Array
(
    [0] => 42S22
    [1] => 1054
    [2] => Unknown column 'level' in 'field list'
)

@pohnean
Copy link
Collaborator

pohnean commented Nov 24, 2021

What are the section types for these entries? Channels, singles, or Structure? Can you provide a screenshot of where the error occured?

@stevecomrie
Copy link

I'm also experiencing this issue.

I've narrowed it down to whether or not the section that I'm trying to search contains an "Entries" field type that has "Use this field’s values as search keywords" enabled.

The related entry field that I'm trying to make searchable/filterable is a Channel.

@stevecomrie
Copy link

Here's a short screencast I did of toggling the field on / off and the error that I'm seeing:

Kazam.mp4

@sonoflee
Copy link
Author

sonoflee commented Nov 24, 2021

What are the section types for these entries? Channels, singles, or Structure? Can you provide a screenshot of where the error occured?

Both of the affected section types are Channels. Attaching a screen grab of what happens:

Screen.Recording.2021-11-24.at.12.55.49.PM.mov

both of the affected channels do have "Entries" fields with "Use this field’s values as search keywords" checked, like @stevecomrie - I haven't yet been able to test whether unchecking will fix the issue yet but will look into that ASAP

@stevecomrie
Copy link

@stevecomrie - I haven't yet been able to test whether unchecking will fix the issue yet but will look into that ASAP

Unchecking that box won't "fix" the issue, but it will prevent that field from showing up in the filter selection list. At best it's a stop-gap replacement that will still let you use most filters except the one field that's throwing errors.

@pohnean
Copy link
Collaborator

pohnean commented Nov 25, 2021

Thanks everyone. I'm investigating the issue now.

pohnean added a commit that referenced this issue Nov 25, 2021
…aft CMS v3.7.22 ([GH Issue #15](#15))

- Bugfix: Duplicate fields are now removed. ([GH Issue #17](#17))
@pohnean
Copy link
Collaborator

pohnean commented Nov 25, 2021

Fixed in 1.2.3.

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

3 participants