In my view, the filter: Node: Level Tweet is not being applied:
here the view:
$view = new view;
$view->name = 'search_tweets_hash';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'search_api_index_default_node_index';
$view->human_name = 'Search Tweets Hash';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Search Tweets Hash';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '13';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['inline'] = array(
'field_arroba' => 'field_arroba',
'field_hash' => 'field_hash',
);
$handler->display->display_options['row_options']['separator'] = ' ';
$handler->display->display_options['row_options']['hide_empty'] = 0;
$handler->display->display_options['row_options']['default_field_elements'] = 1;
/* Field: Node: Node ID */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['label'] = '';
$handler->display->display_options['fields']['nid']['exclude'] = TRUE;
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['nid']['alter']['external'] = 0;
$handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
$handler->display->display_options['fields']['nid']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['nid']['link_to_entity'] = 0;
/* Field: Node: Profile Image */
$handler->display->display_options['fields']['field_profile_image_url']['id'] = 'field_profile_image_url';
$handler->display->display_options['fields']['field_profile_image_url']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_profile_image_url']['field'] = 'field_profile_image_url';
$handler->display->display_options['fields']['field_profile_image_url']['label'] = '';
$handler->display->display_options['fields']['field_profile_image_url']['alter']['alter_text'] = 1;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['text'] = '<img src=\'[field_profile_image_url]\' alt=\'[title]\' />';
$handler->display->display_options['fields']['field_profile_image_url']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_profile_image_url']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_profile_image_url']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['field_profile_image_url']['link_to_entity'] = 0;
/* Field: Node: twitter arroba */
$handler->display->display_options['fields']['field_arroba']['id'] = 'field_arroba';
$handler->display->display_options['fields']['field_arroba']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_arroba']['field'] = 'field_arroba';
$handler->display->display_options['fields']['field_arroba']['label'] = 'From';
$handler->display->display_options['fields']['field_arroba']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_arroba']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_arroba']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_arroba']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_arroba']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_arroba']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_arroba']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_arroba']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_arroba']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['field_arroba']['link_to_entity'] = 0;
$handler->display->display_options['fields']['field_arroba']['format_name'] = 1;
/* Field: Node: twitter hash */
$handler->display->display_options['fields']['field_hash']['id'] = 'field_hash';
$handler->display->display_options['fields']['field_hash']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_hash']['field'] = 'field_hash';
$handler->display->display_options['fields']['field_hash']['label'] = 'In';
$handler->display->display_options['fields']['field_hash']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_hash']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_hash']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_hash']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_hash']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_hash']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_hash']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_hash']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_hash']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['field_hash']['link_to_entity'] = 0;
$handler->display->display_options['fields']['field_hash']['format_name'] = 1;
/* Field: Node: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['path'] = 'http://sport.peoplenews.me/node/[nid] ';
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['title']['link_to_entity'] = 1;
/* Field: Node: Level Tweet */
$handler->display->display_options['fields']['field_level_tweet']['id'] = 'field_level_tweet';
$handler->display->display_options['fields']['field_level_tweet']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['fields']['field_level_tweet']['field'] = 'field_level_tweet';
$handler->display->display_options['fields']['field_level_tweet']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_level_tweet']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_level_tweet']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_level_tweet']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_level_tweet']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['field_level_tweet']['link_to_entity'] = 0;
/* Sort criterion: Node: Date created */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Node: Sección */
$handler->display->display_options['arguments']['field_seccion']['id'] = 'field_seccion';
$handler->display->display_options['arguments']['field_seccion']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['arguments']['field_seccion']['field'] = 'field_seccion';
$handler->display->display_options['arguments']['field_seccion']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['field_seccion']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['field_seccion']['summary']['format'] = 'default_summary';
/* Filter criterion: Node: Content type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'tweet_articulo' => 'tweet_articulo',
);
/* Filter criterion: Node: Level Tweet */
$handler->display->display_options['filters']['field_level_tweet']['id'] = 'field_level_tweet';
$handler->display->display_options['filters']['field_level_tweet']['table'] = 'search_api_index_default_node_index';
$handler->display->display_options['filters']['field_level_tweet']['field'] = 'field_level_tweet';
$handler->display->display_options['filters']['field_level_tweet']['value'] = '0';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'search-tweets-hash';
$translatables['search_tweets_hash'] = array(
t('Master'),
t('Search Tweets Hash'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('<img src=\'[field_profile_image_url]\' alt=\'[title]\' />'),
t('From'),
t('In'),
t('http://sport.peoplenews.me/node/[nid] '),
t('Level Tweet'),
t('All'),
t('Page'),
);
I also atacch the screens of the view paraemters and the view preview
Comments
Comment #1
dawehnerDoes the sql version (not search_api) works for you? If yes please move it to search_api
Comment #2
kars-t commentedClosing this due to long inactivity. Feel free to reopen the issue and provide more information.
Comment #3
kars-t commentedAdding tag
Comment #4
egarias commentedthe sql version (not search_api) works, so it should be a search-api issue
Comment #5
drunken monkeyMaybe the data hasn't been indexed in its latest version? Do the „Level Tweet“ values change (frequently)? Or are they maybe multi-valued?
Comment #6
das-peter commentedI'd say this has to do with the filter value being
0.Currently
SearchApiViewsHandlerFilterskips everything that's interpreted asFALSEby php.This means "",
0,NULLare skipped.But
0should really be applied as filter.Thus I'd suggest to change the check from
if ($this->value) {to
if (strlen($this->value)) {Attached patch does that.
Comment #8
das-peter commented#6: search_api_views-filter-handler-fix-for-zeros.patch queued for re-testing.
Comment #10
das-peter commentedSeriously, I don't get it why the affected test should fail because of this patch :|
Comment #11
colle901 commentedI have a similar problem, but with a text filter. I want to include all content where a text field is null or empty. When I set the filter to "=" (empty value) I get all records returned including those with the value set.
I'm sorry if this is not related to the original issue-- let me know and I can open a separate ticket.
Comment #12
das-peter commented@colle901: Interesting point, my patch definitely won't work out for you, because
strlen()will always be 0.I'd say to solve this we need a special option, otherwise I see conflicts e.g. with the exposed filter, where empty fields are set as GET parameters too.
For the moment I'd suggest following:
A new option for the exposed filter "Allow empty values" which defaults to FALSE.
In situations where the filter isn't exposed the query accepts always all input. But if the filter is exposed its checked whether to allow an empty filter value or not based on the option.
@colle901: Would this work with your use case?
Comment #13
colle901 commentedIf I understand what you are describing correctly, it should work for what I need.
Just for comparison, I have a similar view that does not use Search API where I created a filter on a text field using two conditions with an OR: "=" (empty value) OR "is empty".
This lets through all records where that field is either an empty string or NULL. I am simply looking to duplicate that condition using an indexed string field with Search API.
Comment #14
das-peter commentedAh, thanks for the hint - we could introduce an "is empty" operator to cover such cases.
Comment #15
colle901 commentedAn "is empty" operator would be great.
I was initially confused by the standard views version because I expected it to work more like PHP "empty" (which includes empty strings and zero in addition to NULL), but I was able to get around it by adding the empty string condition. I know I am biased by my particular use case, but I would prefer a PHP style "is empty" operator.
Comment #16
colle901 commentedI am coming up against a deadline soon and was just wondering if this was going to be addressed. I don't have the time to put into it right now. If it helps, my client would be willing to pay for the patch to be completed if it could happen within the next week (as well as correcting this issue). Contact me directly if interested.
Comment #17
lucascaro commentedwhat if you use isset($this->value) instead of strlen?
Comment #18
becw commentedI think that it makes sense not to apply an "=" filter if the filter value is empty, but it there should be an empty/not empty filter.
Here's a patch that adds "is null" and "is not null" operators to the search_api_views filter handler. I've tested this with the Solr integration (and it works with no modifications to search_api_solr), but we may need to add support for this to other search backends' service classes.
Comment #20
rafaqz commented#18 working well for me, thanks for the patch.
Comment #21
egarias commentedI am using db search
the filter node promoted = 0 doesn't work for me.
Comment #22
orakili commented#18: 1318904-18-search_api-null_views_filter.patch queued for re-testing.
Comment #24
orakili commentedNew patch that also adds the empty operator for the date and options filters.
Note that I used "empty" and "not empty" for the operators' name like in the views_handler_filter_in_operator etc.
Comment #26
orakili commentedWrong version, it's for 7.x-1.x-dev
Re-attaching the same patch as in #24.
Comment #27
drunken monkeyGreat work, everyone, thanks! Seems to work great!
Also good catch, Peter! Didn't see that …
Attached is a patch combining both the bug fix and the feature (although this should have been done in a separate issue). Also, I improved the admin summaries.
Please test whether this still works as expected!
Comment #28
jonloh commentedI've applied the patch. which is showing the additional operators. However, when I tried to filter a field, it doesn't seem to take effect on the query.
For example, I would like to filter out indexed node with field_a that are not empty. When I update preview, it still shows both empty and not empty nodes.
Comment #29
orakili commentedIt will only work if the Search API backend handles NULL values for filters. It should work fine with Search API Sphinx and Search API elascticsearch but I don't know for others. Patching those backends may be needed to have the intended effect.
Comment #30
drunken monkeyCommitted. Thanks everyone!