Search with asp.net client

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.

Mysql is not required at all.

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

@Nick , @barryhunter , @Sergey

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.

Please help me and suggest solution for this.

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.

I am using Manticore 6.0.4

Assembly ManticoreSearch, Version=0.0.0.0

Here is my created table

var utilsApi = new UtilsApi();
			string tableBody = "create table if not exists products (ProductId text, Name text,Sku text,ShortDescription text,FullDescription text,Price float,Published bool,ManufacturerPartNumber text,CreatedOnUtc timestamp,VendorId integer,Vendor text)";
			utilsApi.Sql(tableBody, true);

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.

Hello team Manticore,

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.

Please help me for this

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.

Hello team Manticore,

var match = "{\"bool\":{\"must\":[" +
		"{\"match\": { \"name,sku\": { \"query\": \"" + keywords + "\", \"operator\":\"or\" }}}" +
		"{\"in\": { \"all(categoryids)\": " + [1] + " }}," +
		"{\"range\": {\"price\":{\"gte\":" + priceMin + ",\"lte\":" + priceMax + "}}}" +
		"]}}";

I want to search with keywords = lenovo in my category Id = 1 and
I passed priceMin = 0 and priceMax = 10000 in above code

I tried this but getting error.
What is wrong with this query ?
Please help me

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 ?

Hi,

{
 "bool": {
   "must": [
      {
        "match": { 
          "name,sku": {
           "query":  keywords, 
           "operator": "or" 
          }
        }
      }
      {
        "in": {
          "all(categoryids)": [1]
         }
      },
      {
        "range": {
          "price": {
            "gte": priceMin,
            "lte": priceMax
           }
         }
       }
   ]
 }
}

At first glance, your request object may miss a comma after the match filter sub-object. Apart from that, it looks correct.

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);

what should be the value for “expr1” ?
match or equals or in ?
or some thing different ?

The value for expr1 should be any(x='32 GB RAM' for x in CategoryList)

Please read this section Manticore Search Manual: Searching > Filters about how to use multiple AND and OR in a single query.

Okay working fine.
Thanks a lot

Hello team manticore !
I am using asp.net client and just want to total number of records from index
So what should be search request ?or which method I have to call ?

Hello team manticore,
Anyone are there ? Please help me for below query…

I tried with match query and match_phrase but they checked the full word(s) for search.
For example, If want to search products/records with word “photoshop” then currently
i have to pass the full word “photoshop”.
But Even I search with “photo” or “shop”, I want to get all the results which contain “photo” or “shop” not only “photoshop”.
Can you please suggest a solution for this? And I am using asp.net client

Suppose I have a product named “Adobe Photoshop CS4”, if I pass the keyword = “shop” or “photo” or “ado” or “obe” then I want this product in my result or response.

So suggest a possible solution without using SQL…