在分布式系统中使用Neo4j和Lucene(Using Neo4j and Lucene in a distributed system)
我正在考虑将Neo4j作为精简文档存储。 文档存储的一个关键方面是搜索,我知道Neo4j包含Lucene提供的旧版索引的全文搜索。
我非常有兴趣听听分布式环境中Neo4j搜索功能的局限性。 它是否提供分布式索引? 它在哪些方面不如Solr或ElasticSearch? 在我必须安装Solr之前,我能在多长时间内接受它?
- 编辑 -
我们正在尝试整合两种不同的搜索工作。 第一种是标准文本内容搜索。 例如,使用安然电子邮件,我们希望搜索与“香蕉”或“去商店”匹配的每封电子邮件,并将这些文档正文作为回应。 这是人们经常求助于Solr的地方。
第二种情况比较复杂,我们在每个文档中附加了大量的元数据。 我们可能已经决定“这些”电子邮件是深夜醉酒拨号的结果。 现在我想搜索可能是深夜醉酒拨号结果的所有电子邮件。 对于这种元数据,我们认为图形数据库是有序的。
在一个完美的世界中,我可以使用一个平台来执行两个查询。 我很欣赏Neo4j(也不是OrientDB,Arango等)被设计为全文搜索数据库,但我试图理解其局限性。
就数量而言,我们正在进行大规模的批量式夜间更新。 数据内容繁重,有些文档会运行到数百页的文本中,但大多数都是一两页的顺序。
I am looking into Neo4j as a stripped-down document store. A key aspect of document storage is search, and I know Neo4j includes full text search via legacy indices provided by Lucene.
I would be very interested in hearing the limitations of Neo4j search capabilities in a distributed environment. Does it provide a distributed index? In what ways is it inferior to Solr or ElasticSearch? How far can I take it before I must install Solr?
-- EDIT --
We are trying to integrate two distinct search efforts. The first is standard text content search. For instance, using the Enron emails, we want to search for every email that matches "bananas" or "going to the store" and get those document bodies in response. This is where people often turn to Solr.
The second case is more complicated, we have attached a great deal of meta-data to each document. We may have decided that "these" emails were the result of late-night drunk-dialing. Now I want to search for all emails that may have been the result of late-night drunk-dialing. For this kind of meta-data, we believe a graph database is in order.
In a perfect world, I can use one platform to perform both queries. I appreciate that Neo4j (nor OrientDB, Arango, etc) are designed as full text search databases, but I'm trying to understand the limitations thereof.
In terms of volume, we are dealing at a very large scale with batch-style nightly updates. The data is content heavy, with some documents running into hundreds of pages of text, but mostly on the order of a page or two.
原文:https://stackoverflow.com/questions/31295830
最满意答案
capacity
是字符串当前可以容纳的最大字符数,而不必增加。size
是字符串中实际存在的字符数。 他们分离概念的原因是分配内存通常效率低下,因此您尝试通过获取比实际需要的内存更少的内存来分配内存。 (许多数据结构使用“加倍”方法,如果它们的容量达到N
并且需要更多空间,则它们将分配2*N
空间,以避免不久后再次重新分配。)当您使用字符串并且需要更多空间时,
capacity
会自动增加。 您也可以使用reserve
功能手动增加它。
capacity
is the maximum number of characters that the string can currently hold without having to grow.size
is how many characters actually exist in the string. The reason they're separate concepts is that allocating memory is generally inefficient, so you try to allocate as rarely as possible by grabbing more memory than you actually need at one time. (Many data structures use a "doubling" method where, if they hit their capacity ofN
and need more space, they will allocate2*N
space, to avoid having to reallocate again any time soon.)
capacity
will increase automatically as you use the string and require more space. You can also manually increase it using thereserve
function.
相关问答
更多-
std :: string容量大小(std::string capacity size)[2023-09-27]
字符串的容量大小是否总是15的倍数? 没有; 关于std::string容量的唯一保证是s.capacity() >= s.size() 。 一个好的实现可能会使容量呈指数增长,这样每次需要重新分配底层数组时,它的容量就会扩大一倍。 这是std::vector所必需的,这样push_back可以具有分期恒定的时间复杂度,但是对于std::string没有这样的要求。 另外, std::string实现可以执行小型字符串优化,其中比std::string对象本身存储的字符数小于一定数量的字符,而不是存储在动态 ... -
C ++中矢量的初始容量(Initial capacity of vector in C++)[2022-05-24]
该标准没有规定容器的初始capacity应该是什么,因此您依赖于实现。 一个共同的实施将开始在零的能力,但不能保证。 另一方面,没有办法改善你的策略std::vectoriv; iv.reserve(2345); std::vector iv; iv.reserve(2345); 所以坚持下去 The standard doesn't specify what the initial capacity of a container should be, so you're relyin ... -
C ++ - getline是否具有最大字符串或字符容量?(C++ - Does getline have a maximum string or character capacity?)[2023-07-26]
是的,您正确使用了getline 。 确保将其用作while循环或其他条件的条件: while(std::getline(fileIN, str1, '.')) { // process str1 } 并且不要犯这么多其他人试图使用fileIN.good()或!fileIN.eof()或其他任何东西的错误(这只会导致头痛和心痛)。 str1的缓冲区不需要由您清理,因为它由string类管理。 它将根据需要进行扩展,并在变量超出范围时解除分配。 这就是为什么我们喜欢标准库类并在使用原始数组之前三思而 ... -
C ++:为另一个容器内的std :: vector保留容量(C++: Reserve capacity for a std::vector, which is inside another container)[2023-12-20]
你不能。 您必须循环并手动呼叫reserve 。 (就此而言, segments还没有vector ......如何在不存在的矢量中预留空间?:)) You can't. You have to loop through and call reserve manually. (And for that matter there are no vectors inside segments yet.. how could reserve space in a nonexistent vector? :) ) -
我们什么时候需要调用std :: string :: capacity()?(When do we need to call std::string::capacity()?)[2019-12-03]
这是一个很好的问题。 我将冒着火焰战争的风险,说用户代码中的capacity()调用是代码气味。 调用它的唯一原因是在操作中避免内存分配。 在这种情况下,更清晰且更容错的策略是创建一个自己的类(比如limited_length_string )。 可能的实现可能预先分配足够的内存(通过它自己的实现或通过封装std::string并在其上调用reserve() 。 如果您在代码中看到此调用,那么请注意地雷。 如果你写这个电话,那就是你的设计是可疑的信号。 It's a good question. I'm g ... -
C ++自定义类String,将其分配给C风格的String(C++ A self-defined class String assigning it to a C-style String)[2023-04-20]
您的类已经有一个operator=接受一个String作为输入,一个非explicit构造函数接受一个const char*作为输入。 所以, a = "hello"将使用temp对象调用隐式转换,类似于: String a; a.operator=(String("hello")); 真正的问题是你的operator=正在泄漏内存,并没有正确分配新的内存。 在重新分配之前,你没有释放m_pString ,并且你没有为strlen()和strcpy()需要的null终止符分配足够的内存。 String& ... -
c ++字符串中“size”和“capacity”之间的区别?(Difference between “size” and “capacity” in c++ string?)[2024-02-08]
capacity是字符串当前可以容纳的最大字符数,而不必增加。 size是字符串中实际存在的字符数。 他们分离概念的原因是分配内存通常效率低下,因此您尝试通过获取比实际需要的内存更少的内存来分配内存。 (许多数据结构使用“加倍”方法,如果它们的容量达到N并且需要更多空间,则它们将分配2*N空间,以避免不久后再次重新分配。) 当您使用字符串并且需要更多空间时, capacity会自动增加。 您也可以使用reserve功能手动增加它。 capacity is the maximum number of char ... -
如果您只想编写普通的人类可读字符串数据,则不应使用未格式化的I / O函数( read()和write() )。 通常,只有在需要读取和写入紧凑二进制数据时才使用这些函数,这对于初学者来说可能是不必要的。 您可以编写普通的文本行: std::string text = "This is some test data."; { std::ofstream file("data.txt"); file << text << '\n'; } 然后用getline()读回来: { std: ...
-
为什么矢量具有不同的容量而不是尺寸?(Why vector has different capacity and other than the size? [duplicate])[2023-08-17]
原因与向量扩展算法的本质有关。 初始化向量时,应用的额外容量数为0.在第i次需要扩展时,向量将其包含复制到新向量,其容量比当前大小加倍。 这种方法使得大小改变数组的整体思想非常有效,因为在摊销时间(意味着N次操作的平均时间),我们得到O(1)插入复杂度。 你可以看到,在我们向第一个向量添加一个整数后,我们得到的容量为6. http://coliru.stacked-crooked.com/a/f084820652f025b8 The reason is related to the very essence ... -
java代码中的字符是UNICODE吗? 如果是这样,单个char不足以存储UNICODE字符,比例为4:1 。 最后一个字符(+1)是空终止符。 因此,您需要4个字节,即4个char ,在C ++端存储单个Java字符,C ++中以char表示的字符串以空值终止(最后一个字符必须为'\0' ),因此20*4+1 。 Are the characters in the java code UNICODE? If so, a single char isn't enough to store a UNICOD ...