#1 2015-03-08 08:32:02

delphiancoder
Member
Registered: 2015-03-04
Posts: 11

MVCServerMongoDB - Search feature

Hi !

D7 compilation and run is giving me a great experience,  light speed, excellent !

About the 'Search Expression' field on the top of web application,  I see is linked to the function
TBlogApplication.ArticleMatch in the MVCViewModel   module,

how should be works ?  where to look to improve it? or getting work properly ?

my test search  always result in a  'There is no more article corresponding to this research criteria.'

thanks, for any help or suggestion

------------

My little contribution on the demo code, so little more easy to set the IP and Port, in case, like me someone have compiler inside a virtual machine (win XP) and mongo and browser for testing, outside (win 7 x64), on the same machine

added this (on top)


    ServerIP,ServerPort,sServerPort: string;
begin

ServerIP   := '192.168.1.132'; ServerPort := '80';
//ServerIP   := 'localhost';  ServerPort := '8092';

sServerPort:= ':'+ ServerPort; if ServerPort = '80' then sServerPort:='';  //  'hide'  if port 80 on writeln  screen

..
..
      aMongoClient := TMongoClient.Create(ServerIP);
      try
        StaticMongoDBRegisterAll(aServer,aMongoClient.Open('blog'));
        aApplication := TBlogApplication.Create;
        try
          aApplication.Start(aServer);
          aHTTPServer := TSQLHttpServer.Create(ServerPort,aServer,'+',useHttpApiRegisteringURI);
..
..

and modified this:


            writeln('Server launched on port '+ sServerPort +' using ',aHttpServer.HttpServer.ClassName);
            writeln(#10'You can check http://localhost'+ sServerPort +'/blog/mvc-info for information');
            writeln('or point to http://localhost'+ sServerPort +' to access the web app.');

Last edited by delphiancoder (2015-03-08 08:45:14)

Offline

#2 2015-03-08 19:30:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: MVCServerMongoDB - Search feature

As written in the doc, the 'Search Expression' field works only with SQlite3, since it uses FTS3 And FTS4 as backend.
We may change a little the code so that the FTS information would be in SQLite3, and all the other data in MongoDB.
But in this case, you need to not use StaticMongoDBRegisterAll() but register the data tables, use a TSQLRestServerDB, and let the FTS table in the TSQLRestServerDB SQLite3 main backend.
Only problem is that the triggers would not work any more, so the FTS table should be populated by hand, from the Delphi code itself.

Offline

#3 2015-03-10 05:59:39

delphiancoder
Member
Registered: 2015-03-04
Posts: 11

Re: MVCServerMongoDB - Search feature

Thanks for your comment.
It will be really useful with the features you mentioned. After all, SQlite3 limits could be how to distribute the database on many servers, and how about performance with concurrent writing (as web, many read and with high traffic many will also write).
Sorry too technical at my level: what mean trigger need to be coded into delphi source ? and you mean FTS information only could be in SQlite3 and all other data in mongo? but just o a single server.
Also I could mirror the FTS information file on more than one server. You think in this way will be more performance than 'all mongo' solution ? I mean using mongo only for search feature.
example in python: https://github.com/ajdavis/motor-blog   demo: http://emptysqua.re/blog/

Last edited by delphiancoder (2015-03-10 10:16:48)

Offline

#4 2015-03-13 08:58:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: MVCServerMongoDB - Search feature

SQlite3 limits are in fact very high, even in concurrent mode.
If a single executable does access the database file at once - which is the case for a mORMot REST server - then there is no performance penalty with concurrent writing.
If you use mORMot TSQLRestBatch with automatic transactions, the resulting speed is very high, even in concurrent mode.
See http://synopse.info/files/html/Synopse% … tml#TITL_4
In practice, I found a mORMot REST server + SQLite3 to be very valuable with high concurrent numbers of reads and writes - performing better than most client-server SQL engines, with much lower resource needs on the server.

About the "trigger", the following line:

function CreateModel: TSQLModel;
...
  result.Props[TSQLArticleSearch].FTS4WithoutContent(
    TSQLArticle,['title','abstract','content']);

It will create SQL TRIGGERs at SQLite3 level, so that each time the ARTICLE table (i.e. TSQLArticle record) is modified, its 'title','abstract','content' columns will be indexed in the ARTICLESEARCH (i.e. TSQLArticleSearch) FTS4 table.
See also https://www.sqlite.org/lang_createtrigger.html

Offline

Board footer

Powered by FluxBB