I wonder whether someone may be able to help me please.
My eventinfo.eventLabel field in my bigquery table contains the following data:
View View Code red for the BDAT group
SELECT
#select all fields excluding those under the hits record
* EXCEPT (hits),
#start array - this rebuilds the hit record
ARRAY(
SELECT
#unnest the hit field, select each field excluding those under the page record
AS STRUCT * EXCEPT (eventInfo ),
(
SELECT
#select all page fields excluding pageTitle
AS STRUCT eventInfo.* EXCEPT (eventLabel),
#remove the query parameter from the pagePath fields
REGEXP_REPLACE(eventinfo.eventLabel, r'View\sView .*', 'View View redacted') AS eventLabel) AS eventinfo
FROM
UNNEST(hits) ) AS hits
FROM
`bigquery.Tested.ga_sessions_20180801`
I'm trying to remove the "Code red" element of the data and replace it with the term "redacted".
Please note that "Code red" is not the only value and the number of characters can increase and decrease. But the "View View" and "for the" are constant throughout my data.
I know that the problem is the REGEXP REPLACE line, and I can manage to put the "redacted" text into the field, but I've not been able to remove the "Code red" text.
Could someone possibly look at this and offer some guidance on how I may be able to change this.
Many thanks and kind regards
Chris
select
[
REGEXP_REPLACE('View View Code red for the BDAT group', r'View View .*? for the', 'View View redacted for the'),
REGEXP_REPLACE('View View Code blue for the BDAT group', r'View View .*? for the', 'View View redacted for the'),
REGEXP_REPLACE('View View red code for the BDAT group', r'View View .*? for the', 'View View redacted for the')
]
Related
I followed the example on DataTables website, but I can't get my filtering field to find what I want.
Let's say I have these strings:
This is a text
This is another text
Text here
Both global and column search, when searching for "text" (case-insensitive), return string 3 only. Why?
This is my code for the search function, almost the same as the examples:
$('#datatable').DataTable()
.columns( colX )
.search( $(this).val(), false, true )
.draw();
I did not implement the search function for global search, so I think it is using the built-in one, I just made the column search.
I have a smart search filter that is filtering news items by tags which all works fine.
The query for the filter dropdown is as follows:
SELECT 'DocumentTags', TagName, TagName FROM CMS_Tag WHERE ##WHERE## ORDER BY ##ORDERBY##
I need to know how to add a default of "All" (essesntially no filter) to this list, but cannot work out how to do it.
The only option I have currently is to tag all documents with "All" tag then this would show up, but hopefully there is another way?
I typically query a default of of empty string, empty string, display text and use a UNION to bind it with the set of results to actually filter by:
SELECT '','','-- Select a Value --'
UNION
SELECT 'DocumentTags', TagName, TagName
FROM CMS_Tag
WHERE ##WHERE##
ORDER BY ##ORDERBY##
Searching "follow back" in Twitter User's description field that I have indexed already with following mapping.
Note: Only Highlight some of mapping.
1.
'analysis' => array(
'analyzer' => array(
'myanalyzer' => array(
"type" => "standard",
'stopwords' => '_none_',
),
)
)
2.
$mapping->setParam('index_analyzer', 'myanalyzer');
$mapping->setParam('search_analyzer', 'myanalyzer');
3.
'description' => array('type' => 'string', "index" => "not_analyzed"),
4.
//search something
$queryString = new \Elastica\Query\QueryString();
$queryString->setDefaultOperator( "AND" );
// $queryString->setFields(array("user.description"));
$queryString->setQuery('follow back');
When Searched while setFields is commented it gives me lot of results like
IF YOU FOLLOW ILL FOLLOW BACK! :) 100% follow back! :)
Follow me i follow back :) instagram:juliemar25 i follow back
But after uncomment setFields and defaultOperator to AND, then it show no results.
AND by uncomment setFields and defaultOperator to OR, it shows me only results that have "follow" in description nothing else.
Q1: Why white space not working on setFields instead working with _all?
While Using Match Query
$matchQuery = new \Elastica\Query\Match();
$matchfield = "user.description";
$queryToMatch = "follow back";
$matchQuery->setFieldQuery($matchfield, $queryToMatch);
It also show only two results that have "follow back" only in description. But after changing to match field to _all it show lot of results that contains "follow back" in description field
Q2. Why it is happening? How can I search for space separated words?
This is because you have set "description" field to be not_analyzed as per the mapping above.
This would result in the description field payload being indexed as is and a match occurs when the 'description' field is an exact search phrase which in this case is "follow back"
Removing "index" => "not_analyzed" should fix it.
This is my jqgrid - $("#list1")
When it loads, i.e. on the gridComplete event, I need to rename the column header texts.
Original column header texts are in this format - Colomn1, Column2 ...
On gridComplete, I change these header texts like this:
$("#list1_Column" + someNumber).text(someText);
However on doing this, I lose the ability to sort columns. Column headers are no longer clickable and hence I cannot sort the grid after this custom programmatic editing.
Similar thing happens when I try changing the texts in the search dropdown list (search modal - using multipleSearch: true)
When, on gridComplete, I change text values in the select list as per the grid column headers, like this -
var select = $('#grid_wrapper #fbox_list1 .ui-widget-content .sf .fields select');
$('#grid_wrapper #fbox_list1 .ui-widget-content .sf .fields select option').remove();
$.each(data, function (i, item) {
select.append('<option value="Column' + item.id + '">' + item.ColumnName + '</option>')
});
...I lose the ability to perform multiple search, i.e. the + and - buttons in the search modal disappear.
How do I get around these two issues? Retaining ability to sort and perform multiple search after having changed column header and search list text values on load.
Please guide.
The column header <th> element has two child elements: one <span> with the text of the column header and another with the sort icons which are hidden the most time. So if you want to change the text manually you should use another selector
$("#list1_Column" + someNumber+ " > span").text(someText);
If you do so you will change the text on the page, but not change the text in the colNames or in the colModel (if you use label property instead of colNames). The text will be used for example to create Multisearch dialog. You can make changes in the colModel with respect of setColProp method or use getGridParam to get reference to any internal parameter of jqGrid (which are objects like inclusive colNames and colModel) and then make any changes which you need.
The best way in my opinion to solve the described problems is to use setLabel method to change the text in the column header:
$("#list1").jqGrid('setLabel','ColumnName','My new Name');
this will solve both problems.
I have a MySQL table containing event data.
On this table, I have a FULLTEXT index, incorporating event_title,event_summary,event_details of types varchar,text,text respectively.
Examples of titles include: "Connections Count", "First Aid", "Health & Safety".
I can search the table as follows:
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('connections');
Which returns the events named "Connections Count" no problem.
However, no matter what I try, I get an empty result set when running the following queries:
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('first aid');
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('first');
SELECT * FROM events WHERE MATCH (event_title,event_summary,event_details) AGAINST ('aid');
I tried renaming an event to "Rich Aid" and could search for that just fine. Also, "First Rich" works great too.
Any ideas of why this is happening or how to fix it would be great!
Thanks for your time.
Rich
"first" is a "stopword" and by default words below 4 caracters are not matched unless you specify ft_min_word_len value.