Firstly, I am amazed at how simple and performant ServiceStack is. Can't believe I've gone without sing this for so long.
I'm especially loving the AutoQuery and Admin feature, but for the life of me, I'm struggling to find documentation on how to extend the response. What I am trying to do is provide a hyperlink in a response to enable navigation right from a row that is returned.
For example, if a list of records are returned from /records, and the primary key (Id field) could actually be a link (ie ABC123) that is its own DTO.
I've noticed the AutoQueryMetadataFeature, so suspect this provides some hints, but very new to the whole solution so any pointers would be very much appreciated.
Cheers
Craig
Is there a way to create a composite primary key on a NetSuite custom record?
I know that is possible to simulate the behavior on an user event script, but I'm looking for the best practice approach here. Maybe a way to define it using SuiteBuilder.
I also know I could trick the "externalid" field to achieve the same results, but is not the real purpose of this field. The concatenation would be a problem too.
Thanks in advance!
The NetSuite team contacted me, it turns out it is not possible to define a composite key on SuiteBuilder.
Anyway, the result can be achieved in other ways, like merging all the values in one big string, or creating an user event script to validate the fields before save.
Full-Text search in Cassandra;
I am fairly new to Cassandra, and wish to understand it more properly. I am attempting to perform a Full-Text search in Cassandra, but after some research I have found that there may not be a "simple" approach for this.. and I say maybe because the first page of Google hasn't said much of anything.
So I am trying to understand now instead, what is the best approach here.. This sort of lead me to take make up my own assumptions based on what I've learned so far about Cassandra, that is based on these two principals; a) design your tables based on your queries, rather than the data, and b) more-data is a good thing, as long as it is being used properly.
With that being said, I've come up with a couple of solutions I'd like to share, and also ask that if anyone has a better idea, please fill me on it before I commit to anything unreasonable/naive.
First Solution: Create a Column Family(CF), with two primary keys and an Index like so:
CREATE TABLE "FullTextSearch" (
"PartialText" text,
"TargetIdentifier" uuid,
"CompleteText" text,
"Type" int,
PRIMARY KEY ("PartialText","TargetIdentifier")
);
CREATE INDEX IX_FullTextSearch_Type "keyspace"."FullTextSearch" ("Type");
With the above table, I would need to insert rows for the text "Hello World" as follows:
BATCH APPLY;
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("H",000000000-0000-0000-0000-000000000,"Hello World",1);
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("He",000000000-0000-0000-0000-000000000,"Hello World",1);
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("Hel",000000000-0000-0000-0000-000000000,"Hello World",1);
.....
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("Hello Wor",000000000-0000-0000-0000-000000000,"Hello World",1);
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("Hello Worl",000000000-0000-0000-0000-000000000,"Hello World",1);
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("Hello World",000000000-0000-0000-0000-000000000,"Hello World",1);
.....
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("Wor",000000000-0000-0000-0000-000000000,"Hello World",1);
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("Worl",000000000-0000-0000-0000-000000000,"Hello World",1);
INSERT INTO "FullTextSearch" ("PartialText","TargetIdentifier","CompleteText","Type") VALUES ("World",000000000-0000-0000-0000-000000000,"Hello World",1);
END BATCH;
Basically, the above will satisfy the following wildcards/partialtext "%o W%", "Hello%", "Worl%"; However it will not satisfy partial words such as "%ell%" for "Hello", which I can feel alright about for now..... (OCD sorta kicks in here)
This approach sort of sucks for me because I would now have to delete/re-insert any time a save/name change occurs on the "TargetIdentifier";
The Second Solution, would be very similar only this time making use of wide-columns; where the table might look like:
CREATE TABLE "FullTextSearch" (
"TargetIdentifier" uuid,
"Type" int,
"CompleteText" text,
PRIMARY KEY("TargetIdentifier")
);
and now during a search something like:
SELECT * FROM "FullTextSearch" WHERE "He" = 1;
so that if the column exists, the respective rows are returned;
Third Solution:
similar to the one above, only this time instead of using wide-columns we use a set column such as map for the partial texts, and perform a query like:
SELECT * FROM "FullTextSearch" WHERE "PartialTexts"['He'] = 1;
Anyways, I am all out of ideas, it is late, and I can only hope for a great response! Please, let me know what I should be doing here... am I even on the right path?
AFAIK Datastax Enterprise Search is the (commercial) successor of Solandra.
Cassandra 2.0 supports so called "custom secondary indexes".
Custom secondary indexes are Java code. Your own implementation has to implement the abstract class org.apache.cassandra.db.index.SecondaryIndex
(See http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/create_index_r.html)
I'm not sure whether implementations exist for Elasticsearch or Solr.
I would not recommend to code all the weird full text search logic like stemming, multiple/exotic language support or even geo spatial stuff.
But SecondaryIndexwould be a good point to start integrating your favorite search engine.
If your dataset is relative small you can simply use a inmemory instance of lucene, update the index at a set interval and you are ready to go.
Use elassandra which comes elasticsearch as a plugin in cassandra.
An example can be found from here
Check out SOLANDRA (former Lucandra)
But I think Solandra is not being actively developed any more, the author moved to Datastax and continued his work there.
So You can also take a look at Datastax Enterprise Search
There are some limitation also, look at DistributedSearch
The very basic thing about cassandra is if you want to use where clause for filtration of records that column is either primary key or you have to assign index to it, so what i can see is you have given primary key to "TargetIdentifier" field and index to "Type" and using "CompleteText" in where clause so this may not work..
Assign secondary index to "CompleteTex" and check whether you are getting desired output or not.
A couple other options you have:
Stratio Lucene Plugin. This uses Lucene for implementing a native secondary index.
You also have SSTable Attached Secondary Index (SASI) available to use for free text searching.
Be forewarned that both of these strategies use locally distributed indexes such that queries will not be very performant since searches will end up being broadcast across the entire cluster. For SASI, you can avoid this if you can use a partition key as part of your query.
Use Solr for fullText search
Cassandra is not good for fullText.
1 Db Cassandra for Archive
2 Solr for full text search
This seems to be a mystery in cassandra, According to official documentation, one can create index on a column by using a custom indexer class
CREATE CUSTOM INDEX ON users (email) USING 'path.to.the.IndexClass';
But I could not find any documentation regarding the interface/class to be implemented/extended to do this and how to configure cassandra to find the class?
I wanted to write a custom indexer which could skip indexing rows based on conditions/options.
Here what I've found https://issues.apache.org/jira/browse/CASSANDRA-6480
So you have to implement a subclass of org.apache.cassandra.db.index.SecondaryIndex and make sure that class is on the classpath for your Cassandra
Here you can find example of implementation:
http://tuplejump.github.io/stargate/
https://github.com/tuplejump/stargate-core
Stratio's Cassandra Lucene Index is a plugin which supports custom indexes in cassandra, you can find the required documentation on how to work with custom indexes.
i try to make composite primary key using cassandr-CLI but i'm unable to do that, i am able to do that using Cqlsh.
can you help me out?
This seems to be addressed in other questions:
Create two composite columns with cassandra-cli
create Composite-keyed Table with cassandra-cli
The constructor CompositeType(keyelem1_type, keyelem2_type, keyelem3_type) should be used in cassandra-cli. Example (from this website providing good overview on composite keys in CQL and cassandra-cli - http://itsallabtamil.blogspot.com/2012/10/cassandra-compositetype-overview-cql.html):
create column family TestComposite
with comparator='CompositeType(UTF8Type, UTF8Type, LongType)'
and key_validation_class = 'UTF8Type',
and defaut_validation_class = 'UTF8Type';
HTH.