Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I have an elastic query as
{
"size": 0,
"aggs": {
"group_by_cluster": {
"terms": {
"field": "cluster"
}
}
}
}
http://localhost:9200/index/type/_search
I am getting the result when tried with postman. Now trying to write corresponding java code. (ElasticSearch version 5.5)
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withIndices("index")
.withTypes("type")
.addAggregation(AggregationBuilders
.global("agg")
.subAggregation(AggregationBuilders.terms("group_by_cluster").field("cluster")))
.build();
Aggregations aggregations = elasticTemplate.query(searchQuery, new
ResultsExtractor<Aggregations>() {
#Override
public Aggregations extract(SearchResponse response) {
return response.getAggregations();
}
} );
But the result is empty. Please help me on this
This was my mistake. Type is case sensitive and I used camelcase in my original code.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
I am new to Dapper and I am doing data retrieval through a stored procedure. Dynamic parameter are successfully added, but not contain data. What have I done wrong?
Here is my code:
connection();
var parameters = new DynamicParameters();
parameters.Add("#FirstName", firstName);
parameters.Add("#SurName", surName);
parameters.Add("#Email", email);
parameters.Add("#SortBy", null);
parameters.Add("#SortDirection", null);
con.Open();
IList<UserModel> userList = SqlMapper.Query<UserModel>(con, "GetAllUser", param: parameters, commandType: CommandType.StoredProcedure).ToList();
con.Close();
return userList.ToList();
Turns out it was an error about the variable name passed in. Must be FirstName not #FirstName. It was confusing not being able to see the value passed in but the search function worked anyway.
The correct code is:
var parameters = new DynamicParameters();
parameters.Add("FirstName", firstName);
//another params
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i am using ASP.NET MVC
i config truthly database
but it saysenter image description here
This is usually an error with your entity framework while trying to perform a database operation. Here is a modified example from TechFunda showing how to see what your entity validation errors are so that you can fix them. If you look at the errorMessage varaible while debugging it should tell you what your actual error is.
public ActionResult ReceiveParameters(PersonalDetails pd)
{
try
{
//Entity Framework Code You are executing
}
catch (DbEntityValidationException ee)
{
foreach (var error in ee.EntityValidationErrors)
{
foreach(var thisError in error.ValidationErrors)
{
var errorMessage = thisError.ErrorMessage;
}
}
}
return View();
}
Source: TechFunda Article
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
i have a vaadin application, and i used SQLContainer to display database records.
the issue that i want to make the SQLcontainer update itself when any database change occurs.
cam anyone help me please?
AFAIK you can't register a "listener" on changes in any database systems like MySQL, Oracle or MSSQL. Its not how databases are intended and architectured to work.
Workaround is to register JavaScript callback in Vaadin and update table every x seconds. This way you won't even need to enable PushMode - it will be still the client who will make requests to the server and not the other (dirty imo) way around.
Following example was tested on MySQL and Vaadin 7.3:
final VerticalLayout layout = new VerticalLayout();
setContent(layout);
final Table table = new Table("Table");
try
{
JDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/test", "root", "");
QueryDelegate qd = new FreeformQuery("select * from testTable", connectionPool, "id");
final SQLContainer c = new SQLContainer(qd);
table.setContainerDataSource(c);
}
catch (SQLException e)
{
e.printStackTrace();
}
layout.addComponent(table);
JavaScript.getCurrent().execute("setInterval(function(){refreshTable();},5000);");
JavaScript.getCurrent().addFunction("refreshTable", new JavaScriptFunction()
{
#Override
public void call(JSONArray arguments) throws JSONException
{
table.refreshRowCache();
}
});
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Does anyone know how to create an immediately-called closure in Swift? I tried my hand at it but I don't think the feature is supported:
// Playground - noun: a place where people can play
import Cocoa
var initialize: () = { () -> () in
var str = "Hello World"
struct Example {
var myString: String
}
}()
println("Hello")
println(str)
Example(myString: "Hello World")
I get the following errors:
Use of unresolved identifier 'str'
Use of unresolved identifier 'Example'
EDIT:
::FACEPALM:: I just realized this is working as expected: anything outside of the scope of that initialize function isn't available to the program, naturally. :P
The closure is being called immediately but the definitions within the braces are lost when the scope of the closure is exited. This works:
var str = "before"
var initialize: () = { () -> () in
str = "Hello World"
}()
println(str)
You are trying to access str that is declared within the scope of the closure, outside of its scope. That will never work.
Also, please note that you are not actually capturing the closure in the initialize variable. In swift, the assignment of variables does not return anything (as indicated by the ()). The only exception to that is in the case of if let and if var
So you can create an immediately called closure but you cannot capture it in a variable.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In C# langauge exists global system variable for this purpose.
Environment.CommandLine
This property provides access to the program name and any arguments specified on the command line when the current process was started.
Dart is asynchronous langauge. It allows self starting processes.
void main() {
task("foo", callback1);
task("baz", callback2);
}
Package tasks.
void task(String name, action()) {
schedule();
addTask(name. action);
}
void schedule() {
// Here we start timer if it not started.
// This timer will get cmd line arguments
// And executes task specified in cmd line arguments
}
P.S.
An official answer from Dart Team: "Not planned".
I cannot understand: "Why this is possible in other platforms through their libraries but in Dart platform this is not possible?".
Why only through "main" parameters which even not ensures that other isolates not substitute these arguments on the surrogate parameters that are not a real OS process command line arguments)?
Here examples:
Go language
func main() {
fmt.Println(len(os.Args), os.Args)
}
Rust language
fn main() {
let args = os::args();
println!("The first argument is {}", args[1]);
}
C# language
class Sample {
public static void Main() {
Console.WriteLine();
String[] arguments = Environment.GetCommandLineArgs();
Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ", arguments));
}
}
Ruby language
ARGV.each do|a|
puts "Argument: #{a}"
end
Python language
import sys
print(sys.argv)
PHP language
foreach($argv as $value)
{
echo "$value\n";
}
Node.js language
process.argv.forEach(function (val, index, array) {
console.log(index + ': ' + val);
});
P.S.
Again, I am convinced that that Dart platform is not like everyone else.
This is only my opinion. It does not change anything.
Thanks, Günter Zöchbauer, for your concern, but do not need to edit this.
If you want to use command-line arguments outside main you have to pass it around. If you want, you can use a global for that.
This behavior is similar to Java, C and C++ (which you forgot to mention).
One big advantage of this approach is, that it is now easy to launch other programs by simply importing them (as a library) and invoking their main. It also makes argument handling more consistent with respect to isolates.