Fantastic elastic search plugin, no search results - elasticsearch

The query generated by the Fantastic ES plugin always returns no results for a search. The SQL statement generated by the query:
SELECT SQL_CALC_FOUND_ROWS wp_posts.*
FROM wp_posts
WHERE 1=1
AND wp_posts.ID IN (0)
AND wp_posts.post_type IN (\'post\', \'page\',\'attachment\', \'events\', \'testimonies\', \'leadership\')
AND (wp_posts.post_status = \'publish\' OR wp_posts.post_author = 1 AND wp_posts.post_status = \'private\')
ORDER BY wp_posts.post_type ASC
LIMIT 0, 500'
It always has wp_posts.ID IN (0) which would seem to always be false? All the posts are in elasticsearch and I am able to run queries on the data from the command line. I am new to Elasticsearch and this plugin, maybe I am missing something simple?

Related

Cassandra select query with Bind Variables in java8

I am trying to execute a Cassandra query in Java8.
My query is
SELECT * FROM customer where aor='north'
and I execute it with
session.execute(query)
and got correct answer.
But then I changed my query to SELECT * FROM customer where aor=?
PreparedStatement statement = session.prepare(query);
BoundStatement boundStatement = statement.bind("'north'");
ResultSet results = session.execute(boundStatement);
for (Row row : results) {
System.out.println(row.toString());
}
This is not working. No errors showing but I am not getting any result.
Can someone please help
When you are using statement.bind("'north'"); it means that you want literally find 'north'.
Just change your string to north and it will work as you wanted

SAP Business Objects Query Builder Query - SI_SESSION_USER

I am trying to get a list of all connections where the SI_SESSION_USER='xyz'.
When I do a query like
select * from si_infoobjects where si_id='00000', I can see this field in the results with that value (xyz).
When I modify the query to look for that specific field and value, it returns zero rows.
I am using:
select * from si_infoobjects where SI_SESSION_USER='xyz'
What query will return the correct results?
Just a guess here, but si_session_user is probably in the Processing Info bag. So use this:
select *
from ci_infoobjects
where si_processinfo.SI_SESSION_USER='xyz'
Note that that's ci_infoobjects not si_infoobjects, but I assume that's just a typo in your question.

Logstash extracting values from sp_executesql

We're tracking and shipping our SQL Server procedure timeouts into Elasticsearch, so we can visualize them in Kibana in order to spot issues.
Some of our SQL queries are parameterized and use sp_executesql.
Would it be possible to extract its parameters and their values from query?
For instance:
EXEC sp_executesql N'EXEC dbo.MySearchProcedure #UserId=#p0,#SearchPhrase=#p1'
, N'#p0 int,#p1 nvarchar(max)'
, #p0 = 11111
, #p1 = N'denmark';
And get this result out of it:
{
"Procedure": "dbo.MySearchProcedure",
"Statement": "exec sp_executesql N'exec Search.GetAnalysisResultsListTextSearch #SubscriberId=#p0,#SearchTerms=#p1,#SortType=#p2',N'#p0 int,#p1 nvarchar(max) ,#p2 int',#p0=47594,#p1=N'denmark',#p2=0",
"Parameters": {
"UserId": 11111,
"SearchPhrase": "denmark"
}
}
Sounds like a job for the ruby{} filter. First, locate all your key=value pair in the query (#userid=#p0, probably using ruby's scan feature), then locate the assignments (#p0=1234, using scan again), then create a new field combining the two (userid=1234). In the ruby filter:
event['userid'] = '1234'

Lucene select all query

Im using 3.6.2 lucene and I try to write query which will select all docs.
Here's some of my code:
searchString = "content:*";
query = parser.parse(QueryParser.escape(searchString));
indexSearcher.search(query, null, collector);
But this request returns only about 25% of docs, I cant get why and how to make such query.
UPDATE
*:* also didn't select all docs, but replacing query with new MatchAllDocsQuery() helped, thanks.
Use MatchAllDocsQuery. It's string representation is *:*.

How to write a query with two ? placeholders in sequence?

I am using a NamedParameterJdbcTemplate, but found that this problem is in the underlying JdbcTemplate class, so I will show the problem as it occurs with the JdbcTemplate (so let's not worry about the safety of the SQL query here).
Here's what I am trying to achieve:
String sql = "SELECT * FROM clients ORDER BY ? ?";
return jdbcTemplate.query(sql,
new Object[] { "name", "ASC" },
new ClientResultSetExtractor());
I expected the first place-holder to be replaced with "name" and the second with "ASC", which would create the valid SQL query:
SELECT * FROM clients ORDER BY name ASC
But unfortunately, running that jdbc query does not work:
ERROR: syntax error at or near "$2" at character 35
STATEMENT: SELECT * FROM clients ORDER BY $1 $2
What am I doing wrong?
EDIT
I had assumed the problem was the two placeholders in sequence, but even when I remove the first one, it still won't accept just the last one, which should tell the query whether to sort in ASC or DESC order. Is this a bug, and if not, why the heck is this not acceptable????
You're trying to use parameters incorrectly.
Parameters are not column names or SQL statement keywords. They're data content (eg., WHERE LastName = ? is a valid parameterized statement, WHERE ? = 'Smith' is not).

Resources