At first sight, your request is fine. Can you please provide us more details: the schema of your index and an example of a document from it? Also, please specify the Manticore version you use.
Here is my table "create table if not exists products1 (name string,producturl string,sku string,oldpricevalue float,published bool,quantity integer,hasdiscountsapplied bool,stockquantity integer, shortdescription text,fulldescription text,showonhomepage bool,price float,createdonutc timestamp)"
And my search request is as mentioned in topic (my question)
I am not using MySQL, I am using MS SQL, So there is any issue with SQL or not ?
You’ve provided the create table. After that the table is empty. Please provide the commands you used to populate the table. Best if you can reproduce the issue with just a single document in the table and provide as many details that will help us reproduce it on our end as possible.
Hello @Nick , @Sergey
MySQL is required or compulsory for Manticore search implementation with asp.net client ?
Anyone please give reply on this, I have confusion about this.
Manticore does have its own SQL based dialect, used for running queries, and is also required to do so some ddl commands. E.g. the ‘create table’ command is in manticores own SQL dialect
It kinda looks similar to mysql but is not mysql.
So the various API clients can’t avoid exposing you to the SQL dialect at times. But many clients can avoid using SQL directly and issue search queries with custom http/JSON protocol under the hood
Below is my json object for single record.
Index name : “products1”
{"Name":"build-your-own-computer 2","ProductUrl":"build-your-own-computer2","Sku":"COMP_CUST_2","ShortDescription":"Digital Storm Vanquish 3 Desktop PC","FullDescription":"<p>Blow the doors off today’s most demanding games with maximum detail, speed, and power for an immersive gaming experience without breaking the bank.</p>\n<p>Stay ahead of the competition, VANQUISH 3 is fully equipped to easily handle future upgrades, keeping your system on the cutting edge for years to come.</p>\n<p>Each system is put through an extensive stress test, ensuring you experience zero bottlenecks and get the maximum performance from your hardware.</p>","Price":1259.0000,"OldPriceValue":0.0000,"Published":true,"Quantity":10000,"HasDiscountsApplied":false,"StockQuantity":1,"ShowOnHomepage":false,"CreatedOnUtc":"2023-03-16T08:51:28.541735"}
Now I want to search with word “build” using c# (asp.net)
So what should be a search request ?
I used below search search request but I got error. var searchRequest = new SearchRequest(index: "products1", query: new { match = new { Name = "build" } }, limit: 100);
Error:
ManticoreSearch.Client.ApiException: 'Cannot deserialize the current JSON array (e.g. [1,2,3]) into type ‘ManticoreSearch.Model.SearchResponse’ because the type requires a JSON object (e.g. {“name”:“value”}) to deserialize correctly.
Hi,
Your initialization of SearchRequest is correct and should work fine.
Can you please specify the versions of Manticore and the C# client you use?
Also, providing the schema of your index would be helpful too.
Can you please run this simple example and see if it produces any error? It has the same data you’ve provided to us. Just change, if necessary, config.BasePath to the one used in your Manticore config.
How to search from list of string ?
I have list of product’s categories name.
Example, I have one product as mentioned in above questions and it has two categories. var categoryList = new List<string>{ "Computer", "Desktop" }
Now, I want to add one fields in my index (or table) for “CategoryList”
So what should be data type for it ? and how to search from that list ?
I checked there is data type “Multi-value integer (MVA)” but I think it is for lists of 32-bit unsigned integers.
But I want to list of strings, so which data type I have to use ?
Can you please suggest and give me an example.
Thank you.
Manticore does not explicitly support string list types, but you can use a workaround with the any function. Assuming that you’ve defined CategoryList as a string attribute in your index, create a document:
var doc = new Dictionary<string, Object> {
{"Name", "test-build-your-own-computer 2"},
{"CategoryList", "Computer Desktop SomeOtherCategory"}
};
var insertDocumentRequest = new InsertDocumentRequest(index: "products1", doc: doc);
After that, you can run a search request like this:
var equalsQuery = new Dictionary<string, Object> { {"any(CategoryList)", new List<string> {"Desktop"} } };
var searchRequest = new SearchRequest(index: "products1", query: new { equals = equalsQuery }, limit: 100);
Yaa, it is ok.
But I want to search in both(Name and CategoryList) or more than 2 fields than what should be search request ?
I have to use “match” condition or use “equals” condition ?
If both at same time then how ? Give me an example please.
How to use search and filter at same time in search request ?
Give me an example for this too please.
If my category name contains white space then it will work ?
I have categories name like “8 GB Pen drive”, “16 GB RAM”, “32 GB RAM”, “256 GB SSD”, “1 TB Hard drive”
Then how to pass value in query in search request ?
In this case, you’ll have to use the json type for your category field and add the expressions field to your search requests like in the example below:
create table if not exists products1 (Name string indexed attribute, CategoryList json)
var doc = new Dictionary<string, Object> {
{"Name", "test-build-your-own-computer 2"},
{"CategoryList", "['16 GB RAM', '32 GB RAM', 'Some other category]"}
};
var insertDocumentRequest = new InsertDocumentRequest(index: "products1", doc: doc);
var expressions = new Dictionary<string, Object> { { "expr1", "any(x='32 GB RAM' for x in CategoryList)" } };
var equalsQuery = new Dictionary<string, Object> { { "expr1", 1 } };
var searchRequest = new SearchRequest(index: "products1", expressions: expressions, query: equalsQuery);