search

Searching phrases in Lucene

纵然是瞬间 提交于 2019-12-18 03:45:16
问题 Could somebody point me to an example how to search for phrases with Lucene.net? Let's say I have in my index a document with field "name", value "Jon Skeet". Now I want to be able to find that document when searching for "jon skeet". 回答1: You can use a proximity search to find terms within a certain distance of each other. The Lucene query syntax looks like this "jon skeet"~3 , meaning find "jon" and "skeet" within three words of each other. With this syntax, relative order doesn't matter;

SOLR df and qf explanation

心不动则不痛 提交于 2019-12-18 03:31:23
问题 I cannot find an adequeate explanation of how these query params interact I am getting suprising (to me) results that if I specify qf=title^20 description^10 then I get no results however if I then add df=description I do get results df is set to text in solrconfig.xml - which will change - but my question is this - does the df setting somehow override the qf setting? this seems odd 回答1: df is the default field and will only take effect if the qf is not defined. I guess you are not using

Recursive search for a node in non-binary tree

风流意气都作罢 提交于 2019-12-18 02:47:57
问题 I want to search for an item in non-binary tree (any node can have n - children) and exit from recursion immediately. The node in question can be any node, not only leafs. This is my code but i don't get complete search. private nNode recursiveSearch(data gi,nNode node){ if (node.getdata()==gi) return node; nNode[] children = node.getChildren(); if (children.length>0) for (int i = 0; i < children.length; i++) { return recursiveSearch(gi, children[i]); } return null; } nNode contains :

How do you search a large text file for a string without going line by line in C#?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 02:40:13
问题 I have a large text file that I need to search for a specific string. Is there a fast way to do this without reading line by line? This method is extremely slow because of the size of the files (more than 100 MB). 回答1: Given the size of the files would you really want to read them entirely into memory beforehand? Line by line is likely to be the best approach here. 回答2: Here is my solution that uses a stream to read in one character at a time. I created a custom class to search for the value

Searching/reading binary data in Python

我的梦境 提交于 2019-12-17 23:16:21
问题 I'm reading in a binary file (a jpg in this case), and need to find some values in that file. For those interested, the binary file is a jpg and I'm attempting to pick out its dimensions by looking for the binary structure as detailed here. I need to find FFC0 in the binary data, skip ahead some number of bytes, and then read 4 bytes (this should give me the image dimensions). What's a good way of searching for the value in the binary data? Is there an equivalent of 'find', or something like

Replace strings in files by Python

孤街浪徒 提交于 2019-12-17 22:51:31
问题 How can you replace the match with the given replacement recursively in a given directory and its subdirectories? Pseudo-code import os import re from os.path import walk for root, dirs, files in os.walk("/home/noa/Desktop/codes"): for name in dirs: re.search("dbname=noa user=noa", "dbname=masi user=masi") // I am trying to replace here a given match in a file 回答1: Put all this code into a file called mass_replace . Under Linux or Mac OS X, you can do chmod +x mass_replace and then just run

how to find the jar file containing a class definition? [closed]

淺唱寂寞╮ 提交于 2019-12-17 22:18:43
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . What is your favorite tool, plugin, script, to find a java class in a bunch of jar files? Very often I inherit code that complains about a class that doesn't exist, and it is just because the jar file is not included in the classpath. But, in what jar file(s) is the class? I may not have the JAR (so I have to

Find and replace a particular term in multiple files

纵然是瞬间 提交于 2019-12-17 22:16:42
问题 How can I replace a particular term in multiple files in Linux? For instance, I have a number of files in my directory: file1.txt file2.txt file3.txt And I need to find a word "searchword" and replace it with "replaceword". 回答1: sed -i.bak 's/searchword/replaceword/g' file*.txt # Or sed -i.bak '/searchword/s/searchword/replaceword/g' file*.txt With bash 4.0, you can do recursive search for files #!/bin/bash shopt -s globstar for file in **/file*.txt do sed -i.bak 's/searchword/replaceword/g'

How can I use a simple Dropdown list in the search box of GridView::widget, Yii2?

亡梦爱人 提交于 2019-12-17 22:07:00
问题 I am trying to make a dropdown list in the search box of a GridView::widget , Yii2 for searching related data. So, how can I create a simple dropdown list in the search box of GridView::widget , Yii2 framework? Thanks. 回答1: You can also use below code [ 'attribute'=>'attribute name', 'filter'=>array("ID1"=>"Name1","ID2"=>"Name2"), ], OR [ 'attribute'=>'attribute name', 'filter'=>ArrayHelper::map(Model::find()->asArray()->all(), 'ID', 'Name'), ], 回答2: Add this in Gridview columns array: [

Faster search in Lucene - Is there a way to keep the whole index in RAM?

浪尽此生 提交于 2019-12-17 21:52:36
问题 Is there a way of keeping the index in RAM instead of keeping it on the hard disk? We want to make searching faster. 回答1: Is there a way of keeping the index in RAM instead of keeping it on the hard disk? Using the RAMDirectory class SampleUsage here Also from the Lucene FAQs ImproveSearchingSpeed Generally for faster indexing performance it's best to flush by RAM usage instead of document count and use as large a RAM buffer as you can. Also check this question: EDIT: RE: RamDirectory , As